linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@conectiva.com.br>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Subject: [RFT][PATCH] oom killer fix ???
Date: Mon, 18 Mar 2002 19:25:19 -0300 (BRT)	[thread overview]
Message-ID: <Pine.LNX.4.44L.0203181923490.2181-100000@imladris.surriel.com> (raw)

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;
 }


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/

                 reply	other threads:[~2002-03-18 22:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44L.0203181923490.2181-100000@imladris.surriel.com \
    --to=riel@conectiva.com.br \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox