Commit 86b1ae38c0a62409dc862a28e3f08920f55f944b
Committed by
Linus Torvalds
1 parent
315c215c0a
Exists in
master
and in
20 other branches
[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>
Showing 2 changed files with 27 additions and 2 deletions Side-by-side Diff
Documentation/sysrq.txt
... | ... | @@ -72,6 +72,8 @@ |
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. |
... | ... | @@ -121,6 +123,9 @@ |
121 | 123 | |
122 | 124 | re'B'oot is good when you're unable to shut down. But you should also 'S'ync |
123 | 125 | and 'U'mount first. |
126 | + | |
127 | +'C'rashdump can be used to manually trigger a crashdump when the system is hung. | |
128 | +The kernel needs to have been built with CONFIG_KEXEC enabled. | |
124 | 129 | |
125 | 130 | 'S'ync is great when your system is locked up, it allows you to sync your |
126 | 131 | disks and will certainly lessen the chance of data loss and fscking. Note |
drivers/char/sysrq.c
... | ... | @@ -35,6 +35,7 @@ |
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,6 +95,21 @@ |
94 | 95 | }; |
95 | 96 | #endif /* CONFIG_VT */ |
96 | 97 | |
98 | +#ifdef CONFIG_KEXEC | |
99 | +/* crashdump sysrq handler */ | |
100 | +static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs, | |
101 | + struct tty_struct *tty) | |
102 | +{ | |
103 | + crash_kexec(); | |
104 | +} | |
105 | +static struct sysrq_key_op sysrq_crashdump_op = { | |
106 | + .handler = sysrq_handle_crashdump, | |
107 | + .help_msg = "Crashdump", | |
108 | + .action_msg = "Trigger a crashdump", | |
109 | + .enable_mask = SYSRQ_ENABLE_DUMP, | |
110 | +}; | |
111 | +#endif | |
112 | + | |
97 | 113 | /* reboot sysrq handler */ |
98 | 114 | static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, |
99 | 115 | struct tty_struct *tty) |
... | ... | @@ -273,8 +289,12 @@ |
273 | 289 | it is handled specially on the sparc |
274 | 290 | and will never arrive */ |
275 | 291 | /* b */ &sysrq_reboot_op, |
276 | -/* c */ NULL, | |
277 | -/* d */ NULL, | |
292 | +#ifdef CONFIG_KEXEC | |
293 | +/* c */ &sysrq_crashdump_op, | |
294 | +#else | |
295 | +/* c */ NULL, | |
296 | +#endif | |
297 | +/* d */ NULL, | |
278 | 298 | /* e */ &sysrq_term_op, |
279 | 299 | /* f */ &sysrq_moom_op, |
280 | 300 | /* g */ NULL, |