53 lines
1.5 KiB
Diff
53 lines
1.5 KiB
Diff
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
|
|
index 0d949c5..8fb2bd9 100644
|
|
--- a/kernel/sysctl.c
|
|
+++ b/kernel/sysctl.c
|
|
@@ -72,6 +72,7 @@ extern int sysctl_overcommit_ratio;
|
|
extern int sysctl_panic_on_oom;
|
|
extern int sysctl_oom_kill_allocating_task;
|
|
extern int sysctl_oom_dump_tasks;
|
|
+extern int sysctl_would_have_oomkilled;
|
|
extern int max_threads;
|
|
extern int core_uses_pid;
|
|
extern int suid_dumpable;
|
|
@@ -1073,6 +1074,14 @@ static struct ctl_table vm_table[] = {
|
|
.proc_handler = &proc_dointvec,
|
|
},
|
|
{
|
|
+ .ctl_name = CTL_UNNUMBERED,
|
|
+ .procname = "would_have_oomkilled",
|
|
+ .data = &sysctl_would_have_oomkilled,
|
|
+ .maxlen = sizeof(sysctl_would_have_oomkilled),
|
|
+ .mode = 0644,
|
|
+ .proc_handler = &proc_dointvec,
|
|
+ },
|
|
+ {
|
|
.ctl_name = VM_OVERCOMMIT_RATIO,
|
|
.procname = "overcommit_ratio",
|
|
.data = &sysctl_overcommit_ratio,
|
|
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
|
|
index ea2147d..788fe84 100644
|
|
--- a/mm/oom_kill.c
|
|
+++ b/mm/oom_kill.c
|
|
@@ -31,6 +31,7 @@
|
|
int sysctl_panic_on_oom;
|
|
int sysctl_oom_kill_allocating_task;
|
|
int sysctl_oom_dump_tasks;
|
|
+int sysctl_would_have_oomkilled;
|
|
static DEFINE_SPINLOCK(zone_scan_lock);
|
|
/* #define DEBUG */
|
|
|
|
@@ -356,6 +357,12 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
|
|
return;
|
|
}
|
|
|
|
+ if (sysctl_would_have_oomkilled == 1) {
|
|
+ printk(KERN_ERR "Would have killed process %d (%s). But continuing instead.\n",
|
|
+ task_pid_nr(p), p->comm);
|
|
+ return;
|
|
+ }
|
|
+
|
|
if (verbose)
|
|
printk(KERN_ERR "Killed process %d (%s)\n",
|
|
task_pid_nr(p), p->comm);
|