1 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2 index b2a2d68..3b132ee 100644
5 @@ -67,6 +67,7 @@ extern int sysctl_overcommit_ratio;
6 extern int sysctl_panic_on_oom;
7 extern int sysctl_oom_kill_allocating_task;
8 extern int sysctl_oom_dump_tasks;
9 +extern int sysctl_would_have_oomkilled;
10 extern int max_threads;
11 extern int core_uses_pid;
12 extern int suid_dumpable;
13 @@ -861,6 +862,14 @@ static struct ctl_table vm_table[] = {
14 .proc_handler = &proc_dointvec,
17 + .ctl_name = CTL_UNNUMBERED,
18 + .procname = "would_have_oomkilled",
19 + .data = &sysctl_would_have_oomkilled,
20 + .maxlen = sizeof(sysctl_would_have_oomkilled),
22 + .proc_handler = &proc_dointvec,
25 .ctl_name = VM_OVERCOMMIT_RATIO,
26 .procname = "overcommit_ratio",
27 .data = &sysctl_overcommit_ratio,
28 diff --git a/mm/oom_kill.c b/mm/oom_kill.c
29 index f255eda..3335a94 100644
33 int sysctl_panic_on_oom;
34 int sysctl_oom_kill_allocating_task;
35 int sysctl_oom_dump_tasks;
36 +int sysctl_would_have_oomkilled;
37 static DEFINE_SPINLOCK(zone_scan_lock);
40 @@ -321,6 +322,12 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
44 + if (sysctl_would_have_oomkilled == 1) {
45 + printk(KERN_ERR "Would have killed process %d (%s). But continuing instead.\n",
46 + task_pid_nr(p), p->comm);
51 printk(KERN_ERR "Killed process %d (%s)\n",
52 task_pid_nr(p), p->comm);
53 @@ -363,6 +370,12 @@ static int oom_kill_task(struct task_struct *p)
55 } while_each_thread(g, q);
57 + if (sysctl_would_have_oomkilled == 1) {
58 + printk(KERN_ERR "Would have killed process %d (%s). But continuing instead.\n",
59 + task_pid_nr(p), p->comm);
63 __oom_kill_task(p, 1);