Skip to content

Commit

Permalink
kmsg_dump: add kmsg_dump() calls to the reboot, halt, poweroff and em…
Browse files Browse the repository at this point in the history
…ergency_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>
  • Loading branch information
Seiji Aguchi authored and torvalds committed Jan 13, 2011
1 parent fc2d557 commit 04c6862
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/linux/kmsg_dump.h
Expand Up @@ -18,6 +18,10 @@ enum kmsg_dump_reason {
KMSG_DUMP_OOPS,
KMSG_DUMP_PANIC,
KMSG_DUMP_KEXEC,
KMSG_DUMP_RESTART,
KMSG_DUMP_HALT,
KMSG_DUMP_POWEROFF,
KMSG_DUMP_EMERG,
};

/**
Expand Down
4 changes: 4 additions & 0 deletions kernel/printk.c
Expand Up @@ -1539,6 +1539,10 @@ static const char * const kmsg_reasons[] = {
[KMSG_DUMP_OOPS] = "oops",
[KMSG_DUMP_PANIC] = "panic",
[KMSG_DUMP_KEXEC] = "kexec",
[KMSG_DUMP_RESTART] = "restart",
[KMSG_DUMP_HALT] = "halt",
[KMSG_DUMP_POWEROFF] = "poweroff",
[KMSG_DUMP_EMERG] = "emergency_restart",
};

static const char *kmsg_to_str(enum kmsg_dump_reason reason)
Expand Down
6 changes: 6 additions & 0 deletions kernel/sys.c
Expand Up @@ -43,6 +43,8 @@
#include <linux/kprobes.h>
#include <linux/user_namespace.h>

#include <linux/kmsg_dump.h>

#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/unistd.h>
Expand Down Expand Up @@ -285,6 +287,7 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)
*/
void emergency_restart(void)
{
kmsg_dump(KMSG_DUMP_EMERG);
machine_emergency_restart();
}
EXPORT_SYMBOL_GPL(emergency_restart);
Expand Down Expand Up @@ -312,6 +315,7 @@ void kernel_restart(char *cmd)
printk(KERN_EMERG "Restarting system.\n");
else
printk(KERN_EMERG "Restarting system with command '%s'.\n", cmd);
kmsg_dump(KMSG_DUMP_RESTART);
machine_restart(cmd);
}
EXPORT_SYMBOL_GPL(kernel_restart);
Expand All @@ -333,6 +337,7 @@ void kernel_halt(void)
kernel_shutdown_prepare(SYSTEM_HALT);
sysdev_shutdown();
printk(KERN_EMERG "System halted.\n");
kmsg_dump(KMSG_DUMP_HALT);
machine_halt();
}

Expand All @@ -351,6 +356,7 @@ void kernel_power_off(void)
disable_nonboot_cpus();
sysdev_shutdown();
printk(KERN_EMERG "Power down.\n");
kmsg_dump(KMSG_DUMP_POWEROFF);
machine_power_off();
}
EXPORT_SYMBOL_GPL(kernel_power_off);
Expand Down

0 comments on commit 04c6862

Please sign in to comment.