Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 376957
b: refs/heads/master
c: cf7df37
h: refs/heads/master
i:
  376955: cbff384
v: v3
  • Loading branch information
Robin Holt authored and Linus Torvalds committed Jun 12, 2013
1 parent 818b965 commit f1b69c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 16e53dbf10a2d7e228709a7286310e629ede5e45
refs/heads/master: cf7df378aa4ff7da3a44769b7ff6e9eef1a9f3db
29 changes: 26 additions & 3 deletions trunk/kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,29 @@ int unregister_reboot_notifier(struct notifier_block *nb)
}
EXPORT_SYMBOL(unregister_reboot_notifier);

/* Add backwards compatibility for stable trees. */
#ifndef PF_NO_SETAFFINITY
#define PF_NO_SETAFFINITY PF_THREAD_BOUND
#endif

static void migrate_to_reboot_cpu(void)
{
/* The boot cpu is always logical cpu 0 */
int cpu = 0;

cpu_hotplug_disable();

/* Make certain the cpu I'm about to reboot on is online */
if (!cpu_online(cpu))
cpu = cpumask_first(cpu_online_mask);

/* Prevent races with other tasks migrating this task */
current->flags |= PF_NO_SETAFFINITY;

/* Make certain I only run on the appropriate processor */
set_cpus_allowed_ptr(current, cpumask_of(cpu));
}

/**
* kernel_restart - reboot the system
* @cmd: pointer to buffer containing command to execute for restart
Expand All @@ -373,7 +396,7 @@ EXPORT_SYMBOL(unregister_reboot_notifier);
void kernel_restart(char *cmd)
{
kernel_restart_prepare(cmd);
disable_nonboot_cpus();
migrate_to_reboot_cpu();
syscore_shutdown();
if (!cmd)
printk(KERN_EMERG "Restarting system.\n");
Expand All @@ -400,7 +423,7 @@ static void kernel_shutdown_prepare(enum system_states state)
void kernel_halt(void)
{
kernel_shutdown_prepare(SYSTEM_HALT);
disable_nonboot_cpus();
migrate_to_reboot_cpu();
syscore_shutdown();
printk(KERN_EMERG "System halted.\n");
kmsg_dump(KMSG_DUMP_HALT);
Expand All @@ -419,7 +442,7 @@ void kernel_power_off(void)
kernel_shutdown_prepare(SYSTEM_POWER_OFF);
if (pm_power_off_prepare)
pm_power_off_prepare();
disable_nonboot_cpus();
migrate_to_reboot_cpu();
syscore_shutdown();
printk(KERN_EMERG "Power down.\n");
kmsg_dump(KMSG_DUMP_POWEROFF);
Expand Down

0 comments on commit f1b69c0

Please sign in to comment.