aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeiji Aguchi <seiji.aguchi@hds.com>2011-01-12 19:59:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-13 11:03:07 -0500
commit04c6862c055fb687c90d9652f32c11a063df15cf (patch)
treeb381c4c2005118f05ce8d2f3d363b73807c0eddf
parentfc2d557c74dc58294b9acc7231a2113ae59af97c (diff)
kmsg_dump: add kmsg_dump() calls to the reboot, halt, poweroff and emergency_restart paths
We need to know the reason why system rebooted in support service. However, we can't inform our customers of the reason because final messages are lost on current Linux kernel. This patch improves the situation above because the final messages are saved by adding kmsg_dump() to reboot, halt, poweroff and emergency_restart path. Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Marco Stornelli <marco.stornelli@gmail.com> Reviewed-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/kmsg_dump.h4
-rw-r--r--kernel/printk.c4
-rw-r--r--kernel/sys.c6
3 files changed, 14 insertions, 0 deletions
diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h
index 24b44145a886..2a0d7d651dc3 100644
--- a/include/linux/kmsg_dump.h
+++ b/include/linux/kmsg_dump.h
@@ -18,6 +18,10 @@ enum kmsg_dump_reason {
18 KMSG_DUMP_OOPS, 18 KMSG_DUMP_OOPS,
19 KMSG_DUMP_PANIC, 19 KMSG_DUMP_PANIC,
20 KMSG_DUMP_KEXEC, 20 KMSG_DUMP_KEXEC,
21 KMSG_DUMP_RESTART,
22 KMSG_DUMP_HALT,
23 KMSG_DUMP_POWEROFF,
24 KMSG_DUMP_EMERG,
21}; 25};
22 26
23/** 27/**
diff --git a/kernel/printk.c b/kernel/printk.c
index f64b8997fc76..0b0c9aa71e89 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1539,6 +1539,10 @@ static const char * const kmsg_reasons[] = {
1539 [KMSG_DUMP_OOPS] = "oops", 1539 [KMSG_DUMP_OOPS] = "oops",
1540 [KMSG_DUMP_PANIC] = "panic", 1540 [KMSG_DUMP_PANIC] = "panic",
1541 [KMSG_DUMP_KEXEC] = "kexec", 1541 [KMSG_DUMP_KEXEC] = "kexec",
1542 [KMSG_DUMP_RESTART] = "restart",
1543 [KMSG_DUMP_HALT] = "halt",
1544 [KMSG_DUMP_POWEROFF] = "poweroff",
1545 [KMSG_DUMP_EMERG] = "emergency_restart",
1542}; 1546};
1543 1547
1544static const char *kmsg_to_str(enum kmsg_dump_reason reason) 1548static const char *kmsg_to_str(enum kmsg_dump_reason reason)
diff --git a/kernel/sys.c b/kernel/sys.c
index 2745dcdb6c6c..31b71a276b40 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -43,6 +43,8 @@
43#include <linux/kprobes.h> 43#include <linux/kprobes.h>
44#include <linux/user_namespace.h> 44#include <linux/user_namespace.h>
45 45
46#include <linux/kmsg_dump.h>
47
46#include <asm/uaccess.h> 48#include <asm/uaccess.h>
47#include <asm/io.h> 49#include <asm/io.h>
48#include <asm/unistd.h> 50#include <asm/unistd.h>
@@ -285,6 +287,7 @@ out_unlock:
285 */ 287 */
286void emergency_restart(void) 288void emergency_restart(void)
287{ 289{
290 kmsg_dump(KMSG_DUMP_EMERG);
288 machine_emergency_restart(); 291 machine_emergency_restart();
289} 292}
290EXPORT_SYMBOL_GPL(emergency_restart); 293EXPORT_SYMBOL_GPL(emergency_restart);
@@ -312,6 +315,7 @@ void kernel_restart(char *cmd)
312 printk(KERN_EMERG "Restarting system.\n"); 315 printk(KERN_EMERG "Restarting system.\n");
313 else 316 else
314 printk(KERN_EMERG "Restarting system with command '%s'.\n", cmd); 317 printk(KERN_EMERG "Restarting system with command '%s'.\n", cmd);
318 kmsg_dump(KMSG_DUMP_RESTART);
315 machine_restart(cmd); 319 machine_restart(cmd);
316} 320}
317EXPORT_SYMBOL_GPL(kernel_restart); 321EXPORT_SYMBOL_GPL(kernel_restart);
@@ -333,6 +337,7 @@ void kernel_halt(void)
333 kernel_shutdown_prepare(SYSTEM_HALT); 337 kernel_shutdown_prepare(SYSTEM_HALT);
334 sysdev_shutdown(); 338 sysdev_shutdown();
335 printk(KERN_EMERG "System halted.\n"); 339 printk(KERN_EMERG "System halted.\n");
340 kmsg_dump(KMSG_DUMP_HALT);
336 machine_halt(); 341 machine_halt();
337} 342}
338 343
@@ -351,6 +356,7 @@ void kernel_power_off(void)
351 disable_nonboot_cpus(); 356 disable_nonboot_cpus();
352 sysdev_shutdown(); 357 sysdev_shutdown();
353 printk(KERN_EMERG "Power down.\n"); 358 printk(KERN_EMERG "Power down.\n");
359 kmsg_dump(KMSG_DUMP_POWEROFF);
354 machine_power_off(); 360 machine_power_off();
355} 361}
356EXPORT_SYMBOL_GPL(kernel_power_off); 362EXPORT_SYMBOL_GPL(kernel_power_off);