diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-01-09 02:38:23 -0500 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-01-09 02:38:23 -0500 |
| commit | da733563be5a9da26fe81d9f007262d00b846e22 (patch) | |
| tree | db28291df94a2043af2123911984c5c173da4e6f /kernel/stop_machine.c | |
| parent | 6ccbcf2cb41131f8d56ef0723bf3f7c1f8486076 (diff) | |
| parent | dab78d7924598ea4031663dd10db814e2e324928 (diff) | |
Merge branch 'next' into for-linus
Diffstat (limited to 'kernel/stop_machine.c')
| -rw-r--r-- | kernel/stop_machine.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index ba5070ce5765..2f194e965715 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include <linux/cpu.h> | 12 | #include <linux/cpu.h> |
| 13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
| 14 | #include <linux/kthread.h> | 14 | #include <linux/kthread.h> |
| 15 | #include <linux/module.h> | 15 | #include <linux/export.h> |
| 16 | #include <linux/percpu.h> | 16 | #include <linux/percpu.h> |
| 17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
| 18 | #include <linux/stop_machine.h> | 18 | #include <linux/stop_machine.h> |
| @@ -41,6 +41,7 @@ struct cpu_stopper { | |||
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper); | 43 | static DEFINE_PER_CPU(struct cpu_stopper, cpu_stopper); |
| 44 | static bool stop_machine_initialized = false; | ||
| 44 | 45 | ||
| 45 | static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo) | 46 | static void cpu_stop_init_done(struct cpu_stop_done *done, unsigned int nr_todo) |
| 46 | { | 47 | { |
| @@ -386,6 +387,8 @@ static int __init cpu_stop_init(void) | |||
| 386 | cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu); | 387 | cpu_stop_cpu_callback(&cpu_stop_cpu_notifier, CPU_ONLINE, bcpu); |
| 387 | register_cpu_notifier(&cpu_stop_cpu_notifier); | 388 | register_cpu_notifier(&cpu_stop_cpu_notifier); |
| 388 | 389 | ||
| 390 | stop_machine_initialized = true; | ||
| 391 | |||
| 389 | return 0; | 392 | return 0; |
| 390 | } | 393 | } |
| 391 | early_initcall(cpu_stop_init); | 394 | early_initcall(cpu_stop_init); |
| @@ -485,6 +488,25 @@ int __stop_machine(int (*fn)(void *), void *data, const struct cpumask *cpus) | |||
| 485 | .num_threads = num_online_cpus(), | 488 | .num_threads = num_online_cpus(), |
| 486 | .active_cpus = cpus }; | 489 | .active_cpus = cpus }; |
| 487 | 490 | ||
| 491 | if (!stop_machine_initialized) { | ||
| 492 | /* | ||
| 493 | * Handle the case where stop_machine() is called | ||
| 494 | * early in boot before stop_machine() has been | ||
| 495 | * initialized. | ||
| 496 | */ | ||
| 497 | unsigned long flags; | ||
| 498 | int ret; | ||
| 499 | |||
| 500 | WARN_ON_ONCE(smdata.num_threads != 1); | ||
| 501 | |||
| 502 | local_irq_save(flags); | ||
| 503 | hard_irq_disable(); | ||
| 504 | ret = (*fn)(data); | ||
| 505 | local_irq_restore(flags); | ||
| 506 | |||
| 507 | return ret; | ||
| 508 | } | ||
| 509 | |||
| 488 | /* Set the initial state and stop all online cpus. */ | 510 | /* Set the initial state and stop all online cpus. */ |
| 489 | set_state(&smdata, STOPMACHINE_PREPARE); | 511 | set_state(&smdata, STOPMACHINE_PREPARE); |
| 490 | return stop_cpus(cpu_online_mask, stop_machine_cpu_stop, &smdata); | 512 | return stop_cpus(cpu_online_mask, stop_machine_cpu_stop, &smdata); |
