From: Hariprasad Nellitheertha Add a sysrq-trigger mechanism for kexec based crashdumps. Alt-Sysrq-c triggers a kexec based crashdump. Signed-off-by: Hariprasad Nellitheertha Signed-off-by: Andrew Morton --- Documentation/sysrq.txt | 5 +++++ drivers/char/sysrq.c | 24 ++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff -puN Documentation/sysrq.txt~kdump-sysrq-trigger-mechanism-for-kexec-based-crashdumps Documentation/sysrq.txt --- 25/Documentation/sysrq.txt~kdump-sysrq-trigger-mechanism-for-kexec-based-crashdumps 2005-05-11 21:15:34.000000000 -0700 +++ 25-akpm/Documentation/sysrq.txt 2005-05-11 21:15:34.000000000 -0700 @@ -72,6 +72,8 @@ On all - write a character to /proc/sys 'b' - Will immediately reboot the system without syncing or unmounting your disks. +'c' - Will perform a kexec reboot in order to take a crashdump. + 'o' - Will shut your system off (if configured and supported). 's' - Will attempt to sync all mounted filesystems. @@ -122,6 +124,9 @@ useful when you want to exit a program t re'B'oot is good when you're unable to shut down. But you should also 'S'ync and 'U'mount first. +'C'rashdump can be used to manually trigger a crashdump when the system is hung. +The kernel needs to have been built with CONFIG_KEXEC enabled. + 'S'ync is great when your system is locked up, it allows you to sync your disks and will certainly lessen the chance of data loss and fscking. Note that the sync hasn't taken place until you see the "OK" and "Done" appear diff -puN drivers/char/sysrq.c~kdump-sysrq-trigger-mechanism-for-kexec-based-crashdumps drivers/char/sysrq.c --- 25/drivers/char/sysrq.c~kdump-sysrq-trigger-mechanism-for-kexec-based-crashdumps 2005-05-11 21:15:34.000000000 -0700 +++ 25-akpm/drivers/char/sysrq.c 2005-05-11 21:15:34.000000000 -0700 @@ -35,6 +35,7 @@ #include #include #include +#include #include #ifdef CONFIG_KGDB_SYSRQ @@ -113,6 +114,21 @@ static struct sysrq_key_op sysrq_unraw_o }; #endif /* CONFIG_VT */ +#ifdef CONFIG_KEXEC +/* crashdump sysrq handler */ +static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs, + struct tty_struct *tty) +{ + crash_kexec(); +} +static struct sysrq_key_op sysrq_crashdump_op = { + .handler = sysrq_handle_crashdump, + .help_msg = "Crashdump", + .action_msg = "Trigger a crashdump", + .enable_mask = SYSRQ_ENABLE_DUMP, +}; +#endif + /* reboot sysrq handler */ static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, struct tty_struct *tty) @@ -297,8 +313,12 @@ static struct sysrq_key_op *sysrq_key_ta it is handled specially on the sparc and will never arrive */ /* b */ &sysrq_reboot_op, -/* c */ NULL, -/* d */ NULL, +#ifdef CONFIG_KEXEC +/* c */ &sysrq_crashdump_op, +#else +/* c */ NULL, +#endif +/* d */ NULL, /* e */ &sysrq_term_op, /* f */ &sysrq_moom_op, /* g */ GDB_OP, _