[PATCH] kdump: sysrq trigger mechanism for kexec based crashdumps

Add a sysrq-trigger mechanism for kexec based crashdumps. Alt-Sysrq-c
triggers a kexec based crashdump.

Signed-off-by: Hariprasad Nellitheertha <hari@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Hariprasad Nellitheertha and committed by
Linus Torvalds
86b1ae38 315c215c

+27 -2
+5
Documentation/sysrq.txt
··· 72 72 'b' - Will immediately reboot the system without syncing or unmounting 73 73 your disks. 74 74 75 + 'c' - Will perform a kexec reboot in order to take a crashdump. 76 + 75 77 'o' - Will shut your system off (if configured and supported). 76 78 77 79 's' - Will attempt to sync all mounted filesystems. ··· 123 121 124 122 re'B'oot is good when you're unable to shut down. But you should also 'S'ync 125 123 and 'U'mount first. 124 + 125 + 'C'rashdump can be used to manually trigger a crashdump when the system is hung. 126 + The kernel needs to have been built with CONFIG_KEXEC enabled. 126 127 127 128 'S'ync is great when your system is locked up, it allows you to sync your 128 129 disks and will certainly lessen the chance of data loss and fscking. Note
+22 -2
drivers/char/sysrq.c
··· 35 35 #include <linux/spinlock.h> 36 36 #include <linux/vt_kern.h> 37 37 #include <linux/workqueue.h> 38 + #include <linux/kexec.h> 38 39 39 40 #include <asm/ptrace.h> 40 41 ··· 94 93 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 95 94 }; 96 95 #endif /* CONFIG_VT */ 96 + 97 + #ifdef CONFIG_KEXEC 98 + /* crashdump sysrq handler */ 99 + static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs, 100 + struct tty_struct *tty) 101 + { 102 + crash_kexec(); 103 + } 104 + static struct sysrq_key_op sysrq_crashdump_op = { 105 + .handler = sysrq_handle_crashdump, 106 + .help_msg = "Crashdump", 107 + .action_msg = "Trigger a crashdump", 108 + .enable_mask = SYSRQ_ENABLE_DUMP, 109 + }; 110 + #endif 97 111 98 112 /* reboot sysrq handler */ 99 113 static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, ··· 289 273 it is handled specially on the sparc 290 274 and will never arrive */ 291 275 /* b */ &sysrq_reboot_op, 292 - /* c */ NULL, 293 - /* d */ NULL, 276 + #ifdef CONFIG_KEXEC 277 + /* c */ &sysrq_crashdump_op, 278 + #else 279 + /* c */ NULL, 280 + #endif 281 + /* d */ NULL, 294 282 /* e */ &sysrq_term_op, 295 283 /* f */ &sysrq_moom_op, 296 284 /* g */ NULL,