From a642bd3d5746ac676df6834bed1cc7f664d62627 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Fri, 1 Oct 2004 17:54:48 +0000 Subject: [PATCH] - Just panic() instead of the default behavior of selecting processes for death. --- mm/oom_panic.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 mm/oom_panic.c diff --git a/mm/oom_panic.c b/mm/oom_panic.c new file mode 100644 index 000000000..b782934ac --- /dev/null +++ b/mm/oom_panic.c @@ -0,0 +1,51 @@ +/* + * Just panic() instead of the default behavior of selecting processes + * for death. + * + * Based on + * Modular OOM handlers for 2.6.4 (C) 2003,2004 Tvrtko A. Ursulin + * and + * linux/mm/oom_kill.c (C) 1998,2000 Rik van Riel. + * + * Mark Huang + * + * $Id$ + */ + +#include +#include +#include + +/** + * out_of_memory - is the system out of memory? + */ +void out_of_memory(int gfp_mask) +{ + /* + * oom_lock protects out_of_memory()'s static variables. + * It's a global lock; this is not performance-critical. + */ + static spinlock_t oom_lock = SPIN_LOCK_UNLOCKED; + static unsigned long count; + + spin_lock(&oom_lock); + + /* + * If we have gotten only a few failures, + * we're not really oom. + */ + if (++count < 10) + goto out_unlock; + + /* + * Ok, really out of memory. Panic. + */ + + printk("oom-killer: gfp_mask=0x%x\n", gfp_mask); + show_free_areas(); + + panic("Out Of Memory"); + +out_unlock: + spin_unlock(&oom_lock); +} -- 2.47.0