linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT][PATCH] oom killer fix ???
@ 2002-03-18 22:25 Rik van Riel
  0 siblings, 0 replies; only message in thread
From: Rik van Riel @ 2002-03-18 22:25 UTC (permalink / raw)
  To: linux-mm; +Cc: linux-kernel

Hi,

The -rmap VM has had some problems with the OOM killer
triggering before the machine actually ran out of freeable
memory. The patch below is an attempt at fixing the OOM killer,
it works by:

1) making sure userland allocations can always allocate
   right down to zone->pages_min, albeit slowly

2) not OOM killing if any zone has more than zone->pages_min
   in freeable pages

I'd appreciate it if the CONFIG_DISCONTIGMEM people could give
this patch a try.

thank you,

Rik
-- 
<insert bitkeeper endorsement here>

http://www.surriel.com/		http://distro.conectiva.com/


===== mm/vmscan.c 1.97 vs edited =====
--- 1.97/mm/vmscan.c	Thu Feb 28 20:38:19 2002
+++ edited/mm/vmscan.c	Mon Mar 18 16:57:41 2002
@@ -605,7 +605,7 @@
 	 * Hmm.. Cache shrink failed - time to kill something?
 	 * Mhwahahhaha! This is the part I really like. Giggle.
 	 */
-	if (!ret && free_low(ANY_ZONE) > 0)
+	if (!ret && free_min(ANY_ZONE) > 0)
 		out_of_memory();

 	return ret;
@@ -703,9 +703,11 @@
 	}
 }

+static int kswapd_overloaded;
 DECLARE_WAIT_QUEUE_HEAD(kswapd_wait);
 DECLARE_WAIT_QUEUE_HEAD(kswapd_done);
-#define VM_SHOULD_SLEEP (free_low(ALL_ZONES) > (freepages.min / 2))
+#define VM_SHOULD_SLEEP ((free_low(ALL_ZONES) > (freepages.min / 2)) && \
+				!kswapd_overloaded)

 /**
  * wakeup_kswapd - wake up the pageout daemon
@@ -751,27 +753,25 @@
 {
 	DECLARE_WAITQUEUE(wait, current);

-	/* Enough free RAM, we can easily keep up with memory demand. */
 	add_wait_queue(&kswapd_wait, &wait);
 	set_current_state(TASK_INTERRUPTIBLE);

+	/* Don't let the processes waiting on memory get stuck, ever. */
+	wake_up(&kswapd_done);
+
+	/* Enough free RAM, we can easily keep up with memory demand. */
 	if (free_high(ALL_ZONES) <= 0) {
-		wake_up(&kswapd_done);
 		schedule_timeout(HZ);
 		remove_wait_queue(&kswapd_wait, &wait);
 		return;
 	}
 	remove_wait_queue(&kswapd_wait, &wait);

-	/*
-	 * kswapd is going to sleep for a long time. Wake up the waiters to
-	 * prevent them to get stuck while waiting for us.
-	 */
-	wake_up(&kswapd_done);
-
 	/* OK, the VM is very loaded. Sleep instead of using all CPU. */
+	kswapd_overloaded = 1;
 	set_current_state(TASK_UNINTERRUPTIBLE);
 	schedule_timeout(HZ / 4);
+	kswapd_overloaded = 0;
 	return;
 }



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-03-18 22:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-18 22:25 [RFT][PATCH] oom killer fix ??? Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).