Messages in this thread Patch in this message | | | Subject | Re: [patch 1/2] stop_machine: enable __stop_machine() to be called from the cpu online path | From | Suresh Siddha <> | Date | Tue, 07 Jun 2011 12:12:37 -0700 |
| |
On Tue, 2011-06-07 at 11:42 -0700, H. Peter Anvin wrote: > On 06/07/2011 11:38 AM, Suresh Siddha wrote: > > > > This is kind of a false positive. We are just checking if the calling > > cpu is online/offline (and there is no possible process migration > > between an online and offline cpu). > > > > Is the state not available in a percpu variable of some sort? If not, > shouldn't it be rather than indirecting via a CPU number?
This is what I first thought about but the current percpu cpu_state is arch specific and not all architectures define it.
Thinking a bit more, I should be able to use the stop machine's percpu thread state and use it here. Something like the appended. I am testing and will send the modified patches shortly.
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index c78b0c2..97a1770 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c @@ -153,7 +153,7 @@ static DEFINE_PER_CPU(struct cpu_stop_work, stop_cpus_work); */ int __stop_cpus(const struct cpumask *cpumask, cpu_stop_fn_t fn, void *arg) { - int online = cpu_online(smp_processor_id()); + int online = percpu_read(cpu_stopper.enabled); int include_this_offline = 0; struct cpu_stop_work *work; struct cpu_stop_done done; @@ -513,13 +513,13 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus) .active_cpus = cpus }; /* Include the calling cpu that might not be online yet. */ - if (!cpu_online(smp_processor_id())) + if (!percpu_read(cpu_stopper.enabled)) smdata.num_threads++; /* Set the initial state and stop all online cpus. */ set_state(&smdata, STOPMACHINE_PREPARE); - if (cpu_online(smp_processor_id())) + if (percpu_read(cpu_stopper.enabled)) return stop_cpus(cpu_online_mask, stop_machine_cpu_stop, &smdata); else
| |