Re: [PATCH] oom killer (Core)

From: William Lee Irwin III
Date: Fri Dec 10 2004 - 11:35:22 EST


On Wed, Dec 01, 2004 at 10:49:03AM +0100, tglx@xxxxxxxxxxxxx wrote:
> The oom killer has currently some strange effects when triggered.
> It gets invoked multiple times and the selection of the task to kill
> does not take processes into account which fork a lot of child processes.
> The patch solves this by
> - Preventing reentrancy
> - Checking for memory threshold before selection and kill.
> - Taking child processes into account when selecting the process to kill

It appears the net functional change here is the reentrancy prevention;
the choice of tasks is policy. The functional change may be accomplished
with the following:


Index: linux-2.6.9/mm/oom_kill.c
===================================================================
--- linux-2.6.9.orig/mm/oom_kill.c 2004-10-18 14:54:30.000000000 -0700
+++ linux-2.6.9/mm/oom_kill.c 2004-12-10 08:21:31.000000000 -0800
@@ -237,7 +237,8 @@
static unsigned long first, last, count, lastkill;
unsigned long now, since;

- spin_lock(&oom_lock);
+ if (!spin_trylock(&oom_lock))
+ return;
now = jiffies;
since = now - last;
last = now;
@@ -282,9 +283,7 @@
show_free_areas();

/* oom_kill() sleeps */
- spin_unlock(&oom_lock);
oom_kill();
- spin_lock(&oom_lock);

reset:
/*
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/