diff options
author | Tejun Heo <tj@kernel.org> | 2011-06-23 14:19:27 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-06-27 18:17:07 -0400 |
commit | fd7355ba1e936487f5aae6fc058c6cb300e44a64 (patch) | |
tree | 1f9292a0e34a14c5e47758d96b17f1d2d398b63a /kernel/stop_machine.c | |
parent | 6d3321e8e2b3bf6a5892e2ef673c7bf536e3f904 (diff) |
stop_machine: reorganize stop_cpus() implementation
Refactor the queuing part of the stop cpus work from __stop_cpus() into
queue_stop_cpus_work().
The reorganization is to help future improvements to stop_machine()
and doesn't introduce any behavior difference.
Signed-off-by: Tejun Heo <tj@kernel.org>
Link: http://lkml.kernel.org/r/20110623182056.897818337@sbsiddha-MOBL3.sc.intel.com
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'kernel/stop_machine.c')
-rw-r--r-- | kernel/stop_machine.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index 0cae1cc323dc..4c89ee9fc56b 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -136,10 +136,11 @@ DEFINE_MUTEX(stop_cpus_mutex); | |||
136 | /* static data for stop_cpus */ | 136 | /* static data for stop_cpus */ |
137 | static DEFINE_PER_CPU(struct cpu_stop_work, stop_cpus_work); | 137 | static DEFINE_PER_CPU(struct cpu_stop_work, stop_cpus_work); |
138 | 138 | ||
139 | int __stop_cpus(const struct cpumask *cpumask, cpu_stop_fn_t fn, void *arg) | 139 | static void queue_stop_cpus_work(const struct cpumask *cpumask, |
140 | cpu_stop_fn_t fn, void *arg, | ||
141 | struct cpu_stop_done *done) | ||
140 | { | 142 | { |
141 | struct cpu_stop_work *work; | 143 | struct cpu_stop_work *work; |
142 | struct cpu_stop_done done; | ||
143 | unsigned int cpu; | 144 | unsigned int cpu; |
144 | 145 | ||
145 | /* initialize works and done */ | 146 | /* initialize works and done */ |
@@ -147,9 +148,8 @@ int __stop_cpus(const struct cpumask *cpumask, cpu_stop_fn_t fn, void *arg) | |||
147 | work = &per_cpu(stop_cpus_work, cpu); | 148 | work = &per_cpu(stop_cpus_work, cpu); |
148 | work->fn = fn; | 149 | work->fn = fn; |
149 | work->arg = arg; | 150 | work->arg = arg; |
150 | work->done = &done; | 151 | work->done = done; |
151 | } | 152 | } |
152 | cpu_stop_init_done(&done, cpumask_weight(cpumask)); | ||
153 | 153 | ||
154 | /* | 154 | /* |
155 | * Disable preemption while queueing to avoid getting | 155 | * Disable preemption while queueing to avoid getting |
@@ -161,7 +161,15 @@ int __stop_cpus(const struct cpumask *cpumask, cpu_stop_fn_t fn, void *arg) | |||
161 | cpu_stop_queue_work(&per_cpu(cpu_stopper, cpu), | 161 | cpu_stop_queue_work(&per_cpu(cpu_stopper, cpu), |
162 | &per_cpu(stop_cpus_work, cpu)); | 162 | &per_cpu(stop_cpus_work, cpu)); |
163 | preempt_enable(); | 163 | preempt_enable(); |
164 | } | ||
164 | 165 | ||
166 | static int __stop_cpus(const struct cpumask *cpumask, | ||
167 | cpu_stop_fn_t fn, void *arg) | ||
168 | { | ||
169 | struct cpu_stop_done done; | ||
170 | |||
171 | cpu_stop_init_done(&done, cpumask_weight(cpumask)); | ||
172 | queue_stop_cpus_work(cpumask, fn, arg, &done); | ||
165 | wait_for_completion(&done.completion); | 173 | wait_for_completion(&done.completion); |
166 | return done.executed ? done.ret : -ENOENT; | 174 | return done.executed ? done.ret : -ENOENT; |
167 | } | 175 | } |