1 diff --git a/mm/oom_panic.c b/mm/oom_panic.c
8 + * Just panic() instead of the default behavior of selecting processes
12 + * Modular OOM handlers for 2.6.4 (C) 2003,2004 Tvrtko A. Ursulin
14 + * linux/mm/oom_kill.c (C) 1998,2000 Rik van Riel.
16 + * Mark Huang <mlhuang@cs.princeton.edu>
18 + * $Id: oom_panic.c,v 1.1 2004/10/01 17:54:48 mlhuang Exp $
21 +#include <linux/mm.h>
22 +#include <linux/sched.h>
23 +#include <linux/swap.h>
26 + * out_of_memory - is the system out of memory?
28 +void out_of_memory(int gfp_mask)
31 + * oom_lock protects out_of_memory()'s static variables.
32 + * It's a global lock; this is not performance-critical.
34 + static spinlock_t oom_lock = SPIN_LOCK_UNLOCKED;
35 + static unsigned long count;
37 + spin_lock(&oom_lock);
40 + * If we have gotten only a few failures,
41 + * we're not really oom.
47 + * Ok, really out of memory. Panic.
50 + printk("oom-killer: gfp_mask=0x%x\n", gfp_mask);
53 + panic("Out Of Memory");
56 + spin_unlock(&oom_lock);
59 commit 2e378e38451e7b3929110dc6f13d48587a169afe
60 Author: root <root@rhel6.(none)>
61 Date: Thu Apr 29 10:08:21 2010 -0400
63 linux-2.6-540-oom-kill.patch
65 diff --git a/init/Kconfig b/init/Kconfig
66 index 87fe242..cc782ea 100644
69 @@ -548,6 +548,23 @@ config CGROUP_DEVICE
70 Provides a cgroup implementing whitelists for devices which
71 a process in the cgroup can mknod or open.
77 + This option enables panic() to be called when a system is out of
78 + memory. This feature along with /proc/sys/kernel/panic allows a
79 + different behavior on out-of-memory conditions when the standard
80 + behavior (killing processes in an attempt to recover) does not
87 + depends on !OOM_PANIC
93 diff --git a/mm/oom_kill.c b/mm/oom_kill.c
94 index e0ba2e1..bb123cf 100644
97 @@ -209,6 +209,11 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
101 +#if defined(CONFIG_OOM_PANIC) && defined(CONFIG_OOM_KILLER)
102 +#warning Only define OOM_PANIC or OOM_KILLER; not both
105 +#ifdef CONFIG_OOM_KILLER
107 * Determine the type of allocation constraint.
109 @@ -479,6 +484,7 @@ retry:
111 read_unlock(&tasklist_lock);
116 static BLOCKING_NOTIFIER_HEAD(oom_notify_list);
117 @@ -544,6 +550,7 @@ void clear_zonelist_oom(struct zonelist *zonelist, gfp_t gfp_mask)
119 spin_unlock(&zone_scan_lock);
121 +EXPORT_SYMBOL_GPL(clear_zonelist_oom);
123 long vs_oom_action(unsigned int);
125 @@ -675,3 +682,47 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
126 if (!test_thread_flag(TIF_MEMDIE))
127 schedule_timeout_uninterruptible(1);
129 +#endif /* CONFIG_OOM_KILLER */
131 +#ifdef CONFIG_OOM_PANIC
133 + * out_of_memory - panic if the system out of memory?
135 +void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order)
138 + * oom_lock protects out_of_memory()'s static variables.
139 + * It's a global lock; this is not performance-critical.
141 + static spinlock_t oom_lock = SPIN_LOCK_UNLOCKED;
142 + static unsigned long count;
144 + spin_lock(&oom_lock);
147 + * If we have gotten only a few failures,
148 + * we're not really oom.
150 + if (++count >= 10) {
152 + * Ok, really out of memory. Panic.
155 + printk("oom-killer: gfp_mask=0x%x\n", gfp_mask);
158 + panic("Out Of Memory");
160 + spin_unlock(&oom_lock);
163 +#ifdef CONFIG_CGROUP_MEM_RES_CTLR
164 +void mem_cgroup_out_of_memory(struct mem_cgroup *mem, gfp_t gfp_mask)
167 + panic("Memory cgroup out Of Memory");
172 +#endif /* CONFIG_OOM_PANIC */
173 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
174 index 4b70600..4830639 100644
175 --- a/mm/page_alloc.c
176 +++ b/mm/page_alloc.c
177 @@ -1642,11 +1642,13 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
181 +#ifdef CONFIG_OOM_KILLER
182 /* Acquire the OOM killer lock for the zones in zonelist */
183 if (!try_set_zone_oom(zonelist, gfp_mask)) {
184 schedule_timeout_uninterruptible(1);
190 * Go through the zonelist yet one more time, keep very high watermark
191 @@ -1668,7 +1670,9 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
192 out_of_memory(zonelist, gfp_mask, order);
195 +#ifdef CONFIG_OOM_KILLER
196 clear_zonelist_oom(zonelist, gfp_mask);