linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@transmeta.com>
To: Kanoj Sarcar <kanoj@google.engr.sgi.com>
Cc: "Stephen C. Tweedie" <sct@redhat.com>,
	Ben LaHaise <bcrl@redhat.com>,
	linux-mm@kvack.org
Subject: Re: [patch] first bit of vm balancing fixes for 2.3.52-1
Date: Mon, 20 Mar 2000 14:06:47 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.10.10003201350100.4934-100000@penguin.transmeta.com> (raw)
In-Reply-To: <Pine.LNX.4.10.10003201329470.4818-100000@penguin.transmeta.com>


On Mon, 20 Mar 2000, Linus Torvalds wrote:
> 
> My code expliticly says: ok, walk the list of zones, if any of them have
> plenty of memory free just allocate it.

Ugh. The "plenty" test should take "zone->low_on_memory" into account too.

This should fix that, and get the PF_MEMALLOC case right too.

This way we explicitly try to avoid any zones that are being balanced
(we'll still allocate from such a zone, it's just that we'll go through
the balancing motions first - think of it as a way of saying "we want to
get OUT of the 'low_on_memory' state quicky, not make it worse").

		Linus

-----
--- v2.3.99-pre2/linux/mm/page_alloc.c	Sun Mar 19 18:35:31 2000
+++ linux/mm/page_alloc.c	Mon Mar 20 14:03:34 2000
@@ -271,6 +271,14 @@
 	zone_t **zone = zonelist->zones;
 
 	/*
+	 * If this is a recursive call, we'd better
+	 * do our best to just allocate things without
+	 * further thought.
+	 */
+	if (current->flags & PF_MEMALLOC)
+		goto allocate_ok;
+
+	/*
 	 * (If anyone calls gfp from interrupts nonatomically then it
 	 * will sooner or later tripped up by a schedule().)
 	 *
@@ -283,32 +291,22 @@
 			break;
 		if (!z->size)
 			BUG();
-		/*
-		 * If this is a recursive call, we'd better
-		 * do our best to just allocate things without
-		 * further thought.
-		 */
-		if (!(current->flags & PF_MEMALLOC)) {
-			/* Are we low on memory? */
-			if (z->free_pages <= z->pages_low)
-				continue;
-		}
-		/*
-		 * This is an optimization for the 'higher order zone
-		 * is empty' case - it can happen even in well-behaved
-		 * systems, think the page-cache filling up all RAM.
-		 * We skip over empty zones. (this is not exact because
-		 * we do not take the spinlock and it's not exact for
-		 * the higher order case, but will do it for most things.)
-		 */
-		if (z->free_pages) {
+
+		/* Are we low on memory? Don't make it worse.. */
+		if (!z->low_on_memory && z->free_pages > z->pages_low) {
 			struct page *page = rmqueue(z, order);
 			if (page)
 				return page;
 		}
 	}
+
+	/*
+	 * Ok, no obvious zones were available, start
+	 * balancing things a bit..
+	 */
 	if (zone_balance_memory(zonelist)) {
 		zone = zonelist->zones;
+allocate_ok:
 		for (;;) {
 			zone_t *z = *(zone++);
 			if (!z)

--
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.eu.org/Linux-MM/

      reply	other threads:[~2000-03-20 22:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-13 22:50 Ben LaHaise
2000-03-13 22:55 ` Linus Torvalds
2000-03-13 23:28   ` Kanoj Sarcar
2000-03-13 23:31     ` Linus Torvalds
2000-03-14  0:23       ` Kanoj Sarcar
2000-03-14  0:32         ` Linus Torvalds
2000-03-17 12:35 ` Stephen C. Tweedie
2000-03-20 20:58   ` Kanoj Sarcar
2000-03-20 21:31     ` Linus Torvalds
2000-03-20 22:06       ` Linus Torvalds [this message]

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.10.10003201350100.4934-100000@penguin.transmeta.com \
    --to=torvalds@transmeta.com \
    --cc=bcrl@redhat.com \
    --cc=kanoj@google.engr.sgi.com \
    --cc=linux-mm@kvack.org \
    --cc=sct@redhat.com \
    /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