[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 'b' - Will immediately reboot the system without syncing or unmounting 73 your disks. 74 75 'o' - Will shut your system off (if configured and supported). 76 77 's' - Will attempt to sync all mounted filesystems. ··· 123 124 re'B'oot is good when you're unable to shut down. But you should also 'S'ync 125 and 'U'mount first. 126 127 'S'ync is great when your system is locked up, it allows you to sync your 128 disks and will certainly lessen the chance of data loss and fscking. Note
··· 72 'b' - Will immediately reboot the system without syncing or unmounting 73 your disks. 74 75 + 'c' - Will perform a kexec reboot in order to take a crashdump. 76 + 77 'o' - Will shut your system off (if configured and supported). 78 79 's' - Will attempt to sync all mounted filesystems. ··· 121 122 re'B'oot is good when you're unable to shut down. But you should also 'S'ync 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. 127 128 'S'ync is great when your system is locked up, it allows you to sync your 129 disks and will certainly lessen the chance of data loss and fscking. Note
+22 -2
drivers/char/sysrq.c
··· 35 #include <linux/spinlock.h> 36 #include <linux/vt_kern.h> 37 #include <linux/workqueue.h> 38 39 #include <asm/ptrace.h> 40 ··· 94 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 95 }; 96 #endif /* CONFIG_VT */ 97 98 /* reboot sysrq handler */ 99 static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, ··· 289 it is handled specially on the sparc 290 and will never arrive */ 291 /* b */ &sysrq_reboot_op, 292 - /* c */ NULL, 293 - /* d */ NULL, 294 /* e */ &sysrq_term_op, 295 /* f */ &sysrq_moom_op, 296 /* g */ NULL,
··· 35 #include <linux/spinlock.h> 36 #include <linux/vt_kern.h> 37 #include <linux/workqueue.h> 38 + #include <linux/kexec.h> 39 40 #include <asm/ptrace.h> 41 ··· 93 .enable_mask = SYSRQ_ENABLE_KEYBOARD, 94 }; 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 111 112 /* reboot sysrq handler */ 113 static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, ··· 273 it is handled specially on the sparc 274 and will never arrive */ 275 /* b */ &sysrq_reboot_op, 276 + #ifdef CONFIG_KEXEC 277 + /* c */ &sysrq_crashdump_op, 278 + #else 279 + /* c */ NULL, 280 + #endif 281 + /* d */ NULL, 282 /* e */ &sysrq_term_op, 283 /* f */ &sysrq_moom_op, 284 /* g */ NULL,