From fe071d7e8aae5745c009c808bb8933f22a9e305a Mon Sep 17 00:00:00 2001 From: David Rientjes Date: Tue, 16 Oct 2007 23:25:56 -0700 Subject: oom: add oom_kill_allocating_task sysctl Adds a new sysctl, 'oom_kill_allocating_task', which will automatically kill the OOM-triggering task instead of scanning through the tasklist to find a memory-hogging target. This is helpful for systems with an insanely large number of tasks where scanning the tasklist significantly degrades performance. Cc: Andrea Arcangeli Acked-by: Christoph Lameter Signed-off-by: David Rientjes Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/oom_kill.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'mm/oom_kill.c') diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 6e999c88c503..00d0bd7d6a2b 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -27,6 +27,7 @@ #include int sysctl_panic_on_oom; +int sysctl_oom_kill_allocating_task; static DEFINE_MUTEX(zone_scan_mutex); /* #define DEBUG */ @@ -471,14 +472,16 @@ void out_of_memory(struct zonelist *zonelist, gfp_t gfp_mask, int order) "No available memory (MPOL_BIND)"); break; - case CONSTRAINT_CPUSET: - oom_kill_process(current, points, - "No available memory in cpuset"); - break; - case CONSTRAINT_NONE: if (sysctl_panic_on_oom) panic("out of memory. panic_on_oom is selected\n"); + /* Fall-through */ + case CONSTRAINT_CPUSET: + if (sysctl_oom_kill_allocating_task) { + oom_kill_process(current, points, + "Out of memory (oom_kill_allocating_task)"); + break; + } retry: /* * Rambo mode: Shoot down a process and hope it solves whatever -- cgit v1.2.3-59-g8ed1b