aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchristian@leber.de <christian@leber.de>2005-03-30 16:37:04 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-03-30 16:37:04 -0800
commit1cdac7692c722e09f65e223f152624eaced547c5 (patch)
tree466892fb7a5b1ca45af23a3d2d9d82cef9a3ebd4
parent598ae05567f1304998c3f4ea895f6702fc08ea8c (diff)
downloadhistory-1cdac7692c722e09f65e223f152624eaced547c5.tar.gz
[PATCH] make sysrq-F call oom_kill()
Ky box (2.6.9-final) was yesterday completly stalled (mouse movable and stupid loadmeter was still working) after starting mutt and was swapping for half an hour until I sent SIGTERM to all processes. I suspect it was a 2 GB big galeon process that was the problem. I think sysrq needs a key to call oom_kill manually. From: Coywolf Qi Hunt <coywolf@sosdg.org> Move it into a workqueue to avoid taking VM locks from IRQ context. Signed-off-by: Coywolf Qi Hunt <coywolf@lovecn.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--Documentation/sysrq.txt2
-rw-r--r--drivers/char/sysrq.c23
2 files changed, 23 insertions, 2 deletions
diff --git a/Documentation/sysrq.txt b/Documentation/sysrq.txt
index a1d3ec6292a995..f98c2e31c143e6 100644
--- a/Documentation/sysrq.txt
+++ b/Documentation/sysrq.txt
@@ -92,6 +92,8 @@ On all - write a character to /proc/sysrq-trigger. eg:
it so that only emergency messages like PANICs or OOPSes would
make it to your console.)
+'f' - Will call oom_kill to kill a memory hog process
+
'e' - Send a SIGTERM to all processes, except for init.
'i' - Send a SIGKILL to all processes, except for init.
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 8c385a3f7e64ad..f59f7cbd525bcd 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -31,9 +31,10 @@
#include <linux/suspend.h>
#include <linux/writeback.h>
#include <linux/buffer_head.h> /* for fsync_bdev() */
-
+#include <linux/swap.h>
#include <linux/spinlock.h>
#include <linux/vt_kern.h>
+#include <linux/workqueue.h>
#include <asm/ptrace.h>
@@ -209,6 +210,24 @@ static struct sysrq_key_op sysrq_term_op = {
.enable_mask = SYSRQ_ENABLE_SIGNAL,
};
+static void moom_callback(void *ignored)
+{
+ out_of_memory(GFP_KERNEL);
+}
+
+static DECLARE_WORK(moom_work, moom_callback, NULL);
+
+static void sysrq_handle_moom(int key, struct pt_regs *pt_regs,
+ struct tty_struct *tty)
+{
+ schedule_work(&moom_work);
+}
+static struct sysrq_key_op sysrq_moom_op = {
+ .handler = sysrq_handle_moom,
+ .help_msg = "Full",
+ .action_msg = "Manual OOM execution",
+};
+
static void sysrq_handle_kill(int key, struct pt_regs *pt_regs,
struct tty_struct *tty)
{
@@ -257,7 +276,7 @@ static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = {
/* c */ NULL,
/* d */ NULL,
/* e */ &sysrq_term_op,
-/* f */ NULL,
+/* f */ &sysrq_moom_op,
/* g */ NULL,
/* h */ NULL,
/* i */ &sysrq_kill_op,