pm: schedule sysrq poweroff on boot cpu
authorZhang Rui <[email protected]>
Thu, 24 Jul 2008 04:28:40 +0000 (21:28 -0700)
committerLinus Torvalds <[email protected]>
Thu, 24 Jul 2008 17:47:24 +0000 (10:47 -0700)
schedule sysrq poweroff on boot cpu.

sysrq poweroff needs to disable nonboot cpus, and we need to run this on boot
cpu to avoid any recursion.  http://bugzilla.kernel.org/show_bug.cgi?id=10897

[[email protected]: build fix]
Signed-off-by: Zhang Rui <[email protected]>
Tested-by: Rus <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
Acked-by: Pavel Machek <[email protected]>
Signed-off-by: KOSAKI Motohiro <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
kernel/power/poweroff.c

index 678ec736076b1395b4a16949cb5f595b72bdd616..72016f051477c62941fb7e24697f9b6b87889b96 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/pm.h>
 #include <linux/workqueue.h>
 #include <linux/reboot.h>
+#include <linux/cpumask.h>
 
 /*
  * When the user hits Sys-Rq o to power down the machine this is the
@@ -25,7 +26,8 @@ static DECLARE_WORK(poweroff_work, do_poweroff);
 
 static void handle_poweroff(int key, struct tty_struct *tty)
 {
-       schedule_work(&poweroff_work);
+       /* run sysrq poweroff on boot cpu */
+       schedule_work_on(first_cpu(cpu_online_map), &poweroff_work);
 }
 
 static struct sysrq_key_op     sysrq_poweroff_op = {