Skip to content

Commit fd7355b

Browse files
htejunH. Peter Anvin
authored andcommitted
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>
1 parent 6d3321e commit fd7355b

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

‎kernel/stop_machine.c‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,20 @@ DEFINE_MUTEX(stop_cpus_mutex);
136136
/* static data for stop_cpus */
137137
static DEFINE_PER_CPU(struct cpu_stop_work, stop_cpus_work);
138138

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)
140142
{
141143
struct cpu_stop_work *work;
142-
struct cpu_stop_done done;
143144
unsigned int cpu;
144145

145146
/* initialize works and done */
146147
for_each_cpu(cpu, cpumask) {
147148
work = &per_cpu(stop_cpus_work, cpu);
148149
work->fn = fn;
149150
work->arg = arg;
150-
work->done = &done;
151+
work->done = done;
151152
}
152-
cpu_stop_init_done(&done, cpumask_weight(cpumask));
153153

154154
/*
155155
* 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)
161161
cpu_stop_queue_work(&per_cpu(cpu_stopper, cpu),
162162
&per_cpu(stop_cpus_work, cpu));
163163
preempt_enable();
164+
}
164165

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);
165173
wait_for_completion(&done.completion);
166174
return done.executed ? done.ret : -ENOENT;
167175
}

0 commit comments

Comments
 (0)