diff options
Diffstat (limited to 'kernel/sys.c')
| -rw-r--r-- | kernel/sys.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index b95d3c72ba21..2bbd9a73b54c 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
| @@ -362,6 +362,29 @@ int unregister_reboot_notifier(struct notifier_block *nb) | |||
| 362 | } | 362 | } |
| 363 | EXPORT_SYMBOL(unregister_reboot_notifier); | 363 | EXPORT_SYMBOL(unregister_reboot_notifier); |
| 364 | 364 | ||
| 365 | /* Add backwards compatibility for stable trees. */ | ||
| 366 | #ifndef PF_NO_SETAFFINITY | ||
| 367 | #define PF_NO_SETAFFINITY PF_THREAD_BOUND | ||
| 368 | #endif | ||
| 369 | |||
| 370 | static void migrate_to_reboot_cpu(void) | ||
| 371 | { | ||
| 372 | /* The boot cpu is always logical cpu 0 */ | ||
| 373 | int cpu = 0; | ||
| 374 | |||
| 375 | cpu_hotplug_disable(); | ||
| 376 | |||
| 377 | /* Make certain the cpu I'm about to reboot on is online */ | ||
| 378 | if (!cpu_online(cpu)) | ||
| 379 | cpu = cpumask_first(cpu_online_mask); | ||
| 380 | |||
| 381 | /* Prevent races with other tasks migrating this task */ | ||
| 382 | current->flags |= PF_NO_SETAFFINITY; | ||
| 383 | |||
| 384 | /* Make certain I only run on the appropriate processor */ | ||
| 385 | set_cpus_allowed_ptr(current, cpumask_of(cpu)); | ||
| 386 | } | ||
| 387 | |||
| 365 | /** | 388 | /** |
| 366 | * kernel_restart - reboot the system | 389 | * kernel_restart - reboot the system |
| 367 | * @cmd: pointer to buffer containing command to execute for restart | 390 | * @cmd: pointer to buffer containing command to execute for restart |
| @@ -373,7 +396,7 @@ EXPORT_SYMBOL(unregister_reboot_notifier); | |||
| 373 | void kernel_restart(char *cmd) | 396 | void kernel_restart(char *cmd) |
| 374 | { | 397 | { |
| 375 | kernel_restart_prepare(cmd); | 398 | kernel_restart_prepare(cmd); |
| 376 | disable_nonboot_cpus(); | 399 | migrate_to_reboot_cpu(); |
| 377 | syscore_shutdown(); | 400 | syscore_shutdown(); |
| 378 | if (!cmd) | 401 | if (!cmd) |
| 379 | printk(KERN_EMERG "Restarting system.\n"); | 402 | printk(KERN_EMERG "Restarting system.\n"); |
| @@ -400,7 +423,7 @@ static void kernel_shutdown_prepare(enum system_states state) | |||
| 400 | void kernel_halt(void) | 423 | void kernel_halt(void) |
| 401 | { | 424 | { |
| 402 | kernel_shutdown_prepare(SYSTEM_HALT); | 425 | kernel_shutdown_prepare(SYSTEM_HALT); |
| 403 | disable_nonboot_cpus(); | 426 | migrate_to_reboot_cpu(); |
| 404 | syscore_shutdown(); | 427 | syscore_shutdown(); |
| 405 | printk(KERN_EMERG "System halted.\n"); | 428 | printk(KERN_EMERG "System halted.\n"); |
| 406 | kmsg_dump(KMSG_DUMP_HALT); | 429 | kmsg_dump(KMSG_DUMP_HALT); |
| @@ -419,7 +442,7 @@ void kernel_power_off(void) | |||
| 419 | kernel_shutdown_prepare(SYSTEM_POWER_OFF); | 442 | kernel_shutdown_prepare(SYSTEM_POWER_OFF); |
| 420 | if (pm_power_off_prepare) | 443 | if (pm_power_off_prepare) |
| 421 | pm_power_off_prepare(); | 444 | pm_power_off_prepare(); |
| 422 | disable_nonboot_cpus(); | 445 | migrate_to_reboot_cpu(); |
| 423 | syscore_shutdown(); | 446 | syscore_shutdown(); |
| 424 | printk(KERN_EMERG "Power down.\n"); | 447 | printk(KERN_EMERG "Power down.\n"); |
| 425 | kmsg_dump(KMSG_DUMP_POWEROFF); | 448 | kmsg_dump(KMSG_DUMP_POWEROFF); |
