aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/sysrq.c
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2006-12-12 18:13:32 -0500
committerDave Jones <davej@redhat.com>2006-12-12 18:13:32 -0500
commitf0eef25339f92f7cd4aeea23d9ae97987a5a1e82 (patch)
tree2472e94d39f43a9580a6d2d5d92de0b749023263 /drivers/char/sysrq.c
parent0cfea5dd98205f2fa318836da664a7d7df1afbc1 (diff)
parente1036502e5263851259d147771226161e5ccc85a (diff)
Merge ../linus
Diffstat (limited to 'drivers/char/sysrq.c')
-rw-r--r--drivers/char/sysrq.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index ee3ca8f1768e..05810c8d20bc 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -35,14 +35,15 @@
35#include <linux/vt_kern.h> 35#include <linux/vt_kern.h>
36#include <linux/workqueue.h> 36#include <linux/workqueue.h>
37#include <linux/kexec.h> 37#include <linux/kexec.h>
38#include <linux/irq.h>
38 39
39#include <asm/ptrace.h> 40#include <asm/ptrace.h>
41#include <asm/irq_regs.h>
40 42
41/* Whether we react on sysrq keys or just ignore them */ 43/* Whether we react on sysrq keys or just ignore them */
42int sysrq_enabled = 1; 44int sysrq_enabled = 1;
43 45
44static void sysrq_handle_loglevel(int key, struct pt_regs *pt_regs, 46static void sysrq_handle_loglevel(int key, struct tty_struct *tty)
45 struct tty_struct *tty)
46{ 47{
47 int i; 48 int i;
48 i = key - '0'; 49 i = key - '0';
@@ -58,8 +59,7 @@ static struct sysrq_key_op sysrq_loglevel_op = {
58}; 59};
59 60
60#ifdef CONFIG_VT 61#ifdef CONFIG_VT
61static void sysrq_handle_SAK(int key, struct pt_regs *pt_regs, 62static void sysrq_handle_SAK(int key, struct tty_struct *tty)
62 struct tty_struct *tty)
63{ 63{
64 if (tty) 64 if (tty)
65 do_SAK(tty); 65 do_SAK(tty);
@@ -76,8 +76,7 @@ static struct sysrq_key_op sysrq_SAK_op = {
76#endif 76#endif
77 77
78#ifdef CONFIG_VT 78#ifdef CONFIG_VT
79static void sysrq_handle_unraw(int key, struct pt_regs *pt_regs, 79static void sysrq_handle_unraw(int key, struct tty_struct *tty)
80 struct tty_struct *tty)
81{ 80{
82 struct kbd_struct *kbd = &kbd_table[fg_console]; 81 struct kbd_struct *kbd = &kbd_table[fg_console];
83 82
@@ -95,10 +94,9 @@ static struct sysrq_key_op sysrq_unraw_op = {
95#endif /* CONFIG_VT */ 94#endif /* CONFIG_VT */
96 95
97#ifdef CONFIG_KEXEC 96#ifdef CONFIG_KEXEC
98static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs, 97static void sysrq_handle_crashdump(int key, struct tty_struct *tty)
99 struct tty_struct *tty)
100{ 98{
101 crash_kexec(pt_regs); 99 crash_kexec(get_irq_regs());
102} 100}
103static struct sysrq_key_op sysrq_crashdump_op = { 101static struct sysrq_key_op sysrq_crashdump_op = {
104 .handler = sysrq_handle_crashdump, 102 .handler = sysrq_handle_crashdump,
@@ -110,9 +108,9 @@ static struct sysrq_key_op sysrq_crashdump_op = {
110#define sysrq_crashdump_op (*(struct sysrq_key_op *)0) 108#define sysrq_crashdump_op (*(struct sysrq_key_op *)0)
111#endif 109#endif
112 110
113static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs, 111static void sysrq_handle_reboot(int key, struct tty_struct *tty)
114 struct tty_struct *tty)
115{ 112{
113 lockdep_off();
116 local_irq_enable(); 114 local_irq_enable();
117 emergency_restart(); 115 emergency_restart();
118} 116}
@@ -123,8 +121,7 @@ static struct sysrq_key_op sysrq_reboot_op = {
123 .enable_mask = SYSRQ_ENABLE_BOOT, 121 .enable_mask = SYSRQ_ENABLE_BOOT,
124}; 122};
125 123
126static void sysrq_handle_sync(int key, struct pt_regs *pt_regs, 124static void sysrq_handle_sync(int key, struct tty_struct *tty)
127 struct tty_struct *tty)
128{ 125{
129 emergency_sync(); 126 emergency_sync();
130} 127}
@@ -135,8 +132,7 @@ static struct sysrq_key_op sysrq_sync_op = {
135 .enable_mask = SYSRQ_ENABLE_SYNC, 132 .enable_mask = SYSRQ_ENABLE_SYNC,
136}; 133};
137 134
138static void sysrq_handle_mountro(int key, struct pt_regs *pt_regs, 135static void sysrq_handle_mountro(int key, struct tty_struct *tty)
139 struct tty_struct *tty)
140{ 136{
141 emergency_remount(); 137 emergency_remount();
142} 138}
@@ -148,8 +144,7 @@ static struct sysrq_key_op sysrq_mountro_op = {
148}; 144};
149 145
150#ifdef CONFIG_LOCKDEP 146#ifdef CONFIG_LOCKDEP
151static void sysrq_handle_showlocks(int key, struct pt_regs *pt_regs, 147static void sysrq_handle_showlocks(int key, struct tty_struct *tty)
152 struct tty_struct *tty)
153{ 148{
154 debug_show_all_locks(); 149 debug_show_all_locks();
155} 150}
@@ -163,11 +158,11 @@ static struct sysrq_key_op sysrq_showlocks_op = {
163#define sysrq_showlocks_op (*(struct sysrq_key_op *)0) 158#define sysrq_showlocks_op (*(struct sysrq_key_op *)0)
164#endif 159#endif
165 160
166static void sysrq_handle_showregs(int key, struct pt_regs *pt_regs, 161static void sysrq_handle_showregs(int key, struct tty_struct *tty)
167 struct tty_struct *tty)
168{ 162{
169 if (pt_regs) 163 struct pt_regs *regs = get_irq_regs();
170 show_regs(pt_regs); 164 if (regs)
165 show_regs(regs);
171} 166}
172static struct sysrq_key_op sysrq_showregs_op = { 167static struct sysrq_key_op sysrq_showregs_op = {
173 .handler = sysrq_handle_showregs, 168 .handler = sysrq_handle_showregs,
@@ -176,8 +171,7 @@ static struct sysrq_key_op sysrq_showregs_op = {
176 .enable_mask = SYSRQ_ENABLE_DUMP, 171 .enable_mask = SYSRQ_ENABLE_DUMP,
177}; 172};
178 173
179static void sysrq_handle_showstate(int key, struct pt_regs *pt_regs, 174static void sysrq_handle_showstate(int key, struct tty_struct *tty)
180 struct tty_struct *tty)
181{ 175{
182 show_state(); 176 show_state();
183} 177}
@@ -188,8 +182,19 @@ static struct sysrq_key_op sysrq_showstate_op = {
188 .enable_mask = SYSRQ_ENABLE_DUMP, 182 .enable_mask = SYSRQ_ENABLE_DUMP,
189}; 183};
190 184
191static void sysrq_handle_showmem(int key, struct pt_regs *pt_regs, 185static void sysrq_handle_showstate_blocked(int key, struct tty_struct *tty)
192 struct tty_struct *tty) 186{
187 show_state_filter(TASK_UNINTERRUPTIBLE);
188}
189static struct sysrq_key_op sysrq_showstate_blocked_op = {
190 .handler = sysrq_handle_showstate_blocked,
191 .help_msg = "showBlockedTasks",
192 .action_msg = "Show Blocked State",
193 .enable_mask = SYSRQ_ENABLE_DUMP,
194};
195
196
197static void sysrq_handle_showmem(int key, struct tty_struct *tty)
193{ 198{
194 show_mem(); 199 show_mem();
195} 200}
@@ -208,14 +213,13 @@ static void send_sig_all(int sig)
208 struct task_struct *p; 213 struct task_struct *p;
209 214
210 for_each_process(p) { 215 for_each_process(p) {
211 if (p->mm && p->pid != 1) 216 if (p->mm && !is_init(p))
212 /* Not swapper, init nor kernel thread */ 217 /* Not swapper, init nor kernel thread */
213 force_sig(sig, p); 218 force_sig(sig, p);
214 } 219 }
215} 220}
216 221
217static void sysrq_handle_term(int key, struct pt_regs *pt_regs, 222static void sysrq_handle_term(int key, struct tty_struct *tty)
218 struct tty_struct *tty)
219{ 223{
220 send_sig_all(SIGTERM); 224 send_sig_all(SIGTERM);
221 console_loglevel = 8; 225 console_loglevel = 8;
@@ -227,16 +231,15 @@ static struct sysrq_key_op sysrq_term_op = {
227 .enable_mask = SYSRQ_ENABLE_SIGNAL, 231 .enable_mask = SYSRQ_ENABLE_SIGNAL,
228}; 232};
229 233
230static void moom_callback(void *ignored) 234static void moom_callback(struct work_struct *ignored)
231{ 235{
232 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL], 236 out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL],
233 GFP_KERNEL, 0); 237 GFP_KERNEL, 0);
234} 238}
235 239
236static DECLARE_WORK(moom_work, moom_callback, NULL); 240static DECLARE_WORK(moom_work, moom_callback);
237 241
238static void sysrq_handle_moom(int key, struct pt_regs *pt_regs, 242static void sysrq_handle_moom(int key, struct tty_struct *tty)
239 struct tty_struct *tty)
240{ 243{
241 schedule_work(&moom_work); 244 schedule_work(&moom_work);
242} 245}
@@ -246,8 +249,7 @@ static struct sysrq_key_op sysrq_moom_op = {
246 .action_msg = "Manual OOM execution", 249 .action_msg = "Manual OOM execution",
247}; 250};
248 251
249static void sysrq_handle_kill(int key, struct pt_regs *pt_regs, 252static void sysrq_handle_kill(int key, struct tty_struct *tty)
250 struct tty_struct *tty)
251{ 253{
252 send_sig_all(SIGKILL); 254 send_sig_all(SIGKILL);
253 console_loglevel = 8; 255 console_loglevel = 8;
@@ -259,8 +261,7 @@ static struct sysrq_key_op sysrq_kill_op = {
259 .enable_mask = SYSRQ_ENABLE_SIGNAL, 261 .enable_mask = SYSRQ_ENABLE_SIGNAL,
260}; 262};
261 263
262static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs, 264static void sysrq_handle_unrt(int key, struct tty_struct *tty)
263 struct tty_struct *tty)
264{ 265{
265 normalize_rt_tasks(); 266 normalize_rt_tasks();
266} 267}
@@ -315,7 +316,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
315 /* May be assigned at init time by SMP VOYAGER */ 316 /* May be assigned at init time by SMP VOYAGER */
316 NULL, /* v */ 317 NULL, /* v */
317 NULL, /* w */ 318 NULL, /* w */
318 NULL, /* x */ 319 &sysrq_showstate_blocked_op, /* x */
319 NULL, /* y */ 320 NULL, /* y */
320 NULL /* z */ 321 NULL /* z */
321}; 322};
@@ -360,8 +361,7 @@ static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
360 * This is the non-locking version of handle_sysrq. It must/can only be called 361 * This is the non-locking version of handle_sysrq. It must/can only be called
361 * by sysrq key handlers, as they are inside of the lock 362 * by sysrq key handlers, as they are inside of the lock
362 */ 363 */
363void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, 364void __handle_sysrq(int key, struct tty_struct *tty, int check_mask)
364 int check_mask)
365{ 365{
366 struct sysrq_key_op *op_p; 366 struct sysrq_key_op *op_p;
367 int orig_log_level; 367 int orig_log_level;
@@ -383,7 +383,7 @@ void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty,
383 (sysrq_enabled & op_p->enable_mask)) { 383 (sysrq_enabled & op_p->enable_mask)) {
384 printk("%s\n", op_p->action_msg); 384 printk("%s\n", op_p->action_msg);
385 console_loglevel = orig_log_level; 385 console_loglevel = orig_log_level;
386 op_p->handler(key, pt_regs, tty); 386 op_p->handler(key, tty);
387 } else { 387 } else {
388 printk("This sysrq operation is disabled.\n"); 388 printk("This sysrq operation is disabled.\n");
389 } 389 }
@@ -412,11 +412,11 @@ void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty,
412 * This function is called by the keyboard handler when SysRq is pressed 412 * This function is called by the keyboard handler when SysRq is pressed
413 * and any other keycode arrives. 413 * and any other keycode arrives.
414 */ 414 */
415void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty) 415void handle_sysrq(int key, struct tty_struct *tty)
416{ 416{
417 if (!sysrq_enabled) 417 if (!sysrq_enabled)
418 return; 418 return;
419 __handle_sysrq(key, pt_regs, tty, 1); 419 __handle_sysrq(key, tty, 1);
420} 420}
421EXPORT_SYMBOL(handle_sysrq); 421EXPORT_SYMBOL(handle_sysrq);
422 422