make it compile
[linux-2.6.git] / linux-2.6-debug-vm-would-have-oomkilled.patch
1 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
2 index b2a2d68..3b132ee 100644
3 --- a/kernel/sysctl.c
4 +++ b/kernel/sysctl.c
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,
15         },
16         {
17 +               .ctl_name       = CTL_UNNUMBERED,
18 +               .procname       = "would_have_oomkilled",
19 +               .data           = &sysctl_would_have_oomkilled,
20 +               .maxlen         = sizeof(sysctl_would_have_oomkilled),
21 +               .mode           = 0644,
22 +               .proc_handler   = &proc_dointvec,
23 +       },
24 +       {
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
30 --- a/mm/oom_kill.c
31 +++ b/mm/oom_kill.c
32 @@ -31,6 +31,7 @@
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);
38  /* #define DEBUG */
39  
40 @@ -321,6 +322,12 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
41                 return;
42         }
43  
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);
47 +               return;
48 +       }
49 +
50         if (verbose)
51                 printk(KERN_ERR "Killed process %s(%d:#%u)\n",
52                         p->comm, task_pid_nr(p), p->xid);
53 @@ -363,6 +370,12 @@ static int oom_kill_task(struct task_struct *p)
54                         return 1;
55         } while_each_thread(g, q);
56  
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);
60 +               return 1;
61 +       }
62 +
63         __oom_kill_task(p, 1);
64  
65         /*