Re: [PATCH] kthread: convert stop_machine into a kthread

From: Andrew Morton
Date: Mon Jun 19 2006 - 23:13:47 EST


On Thu, 15 Jun 2006 09:43:31 -0500
"Serge E. Hallyn" <serue@xxxxxxxxxx> wrote:

> Update stop_machine.c to spawn stop_machine as kthreads rather
> than the deprecated kernel_threads.
>
> Signed-off-by: Serge E. Hallyn <serue@xxxxxxxxxx>
>
> ---
>
> kernel/stop_machine.c | 8 ++++++--
> 1 files changed, 6 insertions(+), 2 deletions(-)
>
> ce04ccc88ac3e2e6c3942fe2c8c4b2d5492d8397
> diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
> index dcfb5d7..2dd5a48 100644
> --- a/kernel/stop_machine.c
> +++ b/kernel/stop_machine.c
> @@ -4,6 +4,7 @@ #include <linux/sched.h>
> #include <linux/cpu.h>
> #include <linux/err.h>
> #include <linux/syscalls.h>
> +#include <linux/kthread.h>
> #include <asm/atomic.h>
> #include <asm/semaphore.h>
> #include <asm/uaccess.h>
> @@ -96,11 +97,14 @@ static int stop_machine(void)
> stopmachine_state = STOPMACHINE_WAIT;
>
> for_each_online_cpu(i) {
> + struct task_struct *tsk;
> if (i == raw_smp_processor_id())
> continue;
> - ret = kernel_thread(stopmachine, (void *)(long)i,CLONE_KERNEL);
> - if (ret < 0)
> + tsk = kthread_run(stopmachine, (void *)(long)i, "stopmachine");
> + if (IS_ERR(tsk)) {
> + ret = PTR_ERR(tsk);
> break;
> + }
> stopmachine_num_threads++;
> }
>

OK. But if we're going to convert to the kthread API then stopmachine()
really whould be switched to the more efficient kthread_bind().

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/