diff options
author | Serge E. Hallyn <serue@us.ibm.com> | 2006-06-25 08:49:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 13:01:22 -0400 |
commit | 8bdd1d1250d55afe403ac4affa6ccc5f9e60468f (patch) | |
tree | b7ffa764ccaa88e07753f9a75d837ea47ea9ea01 | |
parent | 2b943cf09d75c0dfbfd22548988df48f6c24c727 (diff) |
[PATCH] kthread: convert stop_machine into a kthread
- Update stop_machine.c to spawn stop_machine as kthreads rather than the
deprecated kernel_threads.
- Update stop_machine to use the more efficient kthread_bind() before
running task in place of set_cpus_allowed() after.
[akpm@osdl.org: remove now-wrong set_cpus_allowed()]
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | kernel/stop_machine.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index dcfb5d731466..2c0aacc37c55 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/cpu.h> | 4 | #include <linux/cpu.h> |
5 | #include <linux/err.h> | 5 | #include <linux/err.h> |
6 | #include <linux/syscalls.h> | 6 | #include <linux/syscalls.h> |
7 | #include <linux/kthread.h> | ||
7 | #include <asm/atomic.h> | 8 | #include <asm/atomic.h> |
8 | #include <asm/semaphore.h> | 9 | #include <asm/semaphore.h> |
9 | #include <asm/uaccess.h> | 10 | #include <asm/uaccess.h> |
@@ -25,13 +26,11 @@ static unsigned int stopmachine_num_threads; | |||
25 | static atomic_t stopmachine_thread_ack; | 26 | static atomic_t stopmachine_thread_ack; |
26 | static DECLARE_MUTEX(stopmachine_mutex); | 27 | static DECLARE_MUTEX(stopmachine_mutex); |
27 | 28 | ||
28 | static int stopmachine(void *cpu) | 29 | static int stopmachine(void *unused) |
29 | { | 30 | { |
30 | int irqs_disabled = 0; | 31 | int irqs_disabled = 0; |
31 | int prepared = 0; | 32 | int prepared = 0; |
32 | 33 | ||
33 | set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu)); | ||
34 | |||
35 | /* Ack: we are alive */ | 34 | /* Ack: we are alive */ |
36 | smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ | 35 | smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ |
37 | atomic_inc(&stopmachine_thread_ack); | 36 | atomic_inc(&stopmachine_thread_ack); |
@@ -85,7 +84,8 @@ static void stopmachine_set_state(enum stopmachine_state state) | |||
85 | 84 | ||
86 | static int stop_machine(void) | 85 | static int stop_machine(void) |
87 | { | 86 | { |
88 | int i, ret = 0; | 87 | int ret = 0; |
88 | unsigned int i; | ||
89 | struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; | 89 | struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 }; |
90 | 90 | ||
91 | /* One high-prio thread per cpu. We'll do this one. */ | 91 | /* One high-prio thread per cpu. We'll do this one. */ |
@@ -96,11 +96,16 @@ static int stop_machine(void) | |||
96 | stopmachine_state = STOPMACHINE_WAIT; | 96 | stopmachine_state = STOPMACHINE_WAIT; |
97 | 97 | ||
98 | for_each_online_cpu(i) { | 98 | for_each_online_cpu(i) { |
99 | struct task_struct *tsk; | ||
99 | if (i == raw_smp_processor_id()) | 100 | if (i == raw_smp_processor_id()) |
100 | continue; | 101 | continue; |
101 | ret = kernel_thread(stopmachine, (void *)(long)i,CLONE_KERNEL); | 102 | tsk = kthread_create(stopmachine, NULL, "stopmachine"); |
102 | if (ret < 0) | 103 | if (IS_ERR(tsk)) { |
104 | ret = PTR_ERR(tsk); | ||
103 | break; | 105 | break; |
106 | } | ||
107 | kthread_bind(tsk, i); | ||
108 | wake_up_process(tsk); | ||
104 | stopmachine_num_threads++; | 109 | stopmachine_num_threads++; |
105 | } | 110 | } |
106 | 111 | ||