linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rik van Riel <riel@conectiva.com.br>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Marcelo Tosatti <marcelo@conectiva.com.br>, linux-kernel@vger.kernel.org
Subject: [PATCH] blindingly stupid 2.2 VM bug
Date: Sat, 18 Nov 2000 22:04:02 -0200 (BRDT)	[thread overview]
Message-ID: <Pine.LNX.4.21.0011182201250.11745-100000@duckman.distro.conectiva> (raw)

Hi Alan,

here's a fix for a blindingly stupid bug that's been in
2.2 for ages (and which I've warned you about a few times
in the last 6 months, and which I've even sent some patches
for).

This patch should make 2.2 VM a bit more stable and should
also fix the complaints from people who's system gets
flooded by "VM: do_try_to_free_pages failed for process XXX"

It's against something suspiciously like 2.2.18-pre15, so
chances are it'll apply cleanly.

regards,

Rik
--
Hollywood goes for world dumbination,
	Trailer at 11.

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



--- ../rpm/BUILD/linux/mm/vmscan.c	Sat Nov 18 21:56:50 2000
+++ linux/mm/vmscan.c	Sun Nov  5 19:36:23 2000
@@ -17,7 +17,6 @@
 #include <linux/smp_lock.h>
 #include <linux/pagemap.h>
 #include <linux/init.h>
-#include <linux/bigmem.h>
 
 #include <asm/pgtable.h>
 
@@ -61,8 +60,7 @@
 
 	if (PageReserved(page_map)
 	    || PageLocked(page_map)
-	    || ((gfp_mask & __GFP_DMA) && !PageDMA(page_map))
-	    || (!(gfp_mask & __GFP_BIGMEM) && PageBIGMEM(page_map)))
+	    || ((gfp_mask & __GFP_DMA) && !PageDMA(page_map)))
 		return 0;
 
 	/*
@@ -156,9 +154,6 @@
 	if (!entry)
 		return 0; /* No swap space left */
 		
-	if (!(page_map = prepare_bigmem_swapout(page_map)))
-		goto out_swap_free;
-
 	vma->vm_mm->rss--;
 	tsk->nswap++;
 	set_pte(page_table, __pte(entry));
@@ -170,14 +165,10 @@
 	set_bit(PG_locked, &page_map->flags);
 
 	/* OK, do a physical asynchronous write to swap.  */
-	rw_swap_page(WRITE, entry, (char *) page_address(page_map), 0);
+	rw_swap_page(WRITE, entry, (char *) page, 0);
 
 	__free_page(page_map);
 	return 1;
-
- out_swap_free:
-	swap_free(entry);
-	return 0;
 }
 
 /*
@@ -400,13 +391,14 @@
 {
 	int priority;
 	int count = SWAP_CLUSTER_MAX;
+	int loopcount = count;
 
 	lock_kernel();
 
 	/* Always trim SLAB caches when memory gets low. */
 	kmem_cache_reap(gfp_mask);
 
-	priority = 5;
+	priority = 6;
 	do {
 		while (shrink_mmap(priority, gfp_mask)) {
 			if (!--count)
@@ -428,12 +420,21 @@
 		}
 
 		shrink_dcache_memory(priority, gfp_mask);
-	} while (--priority > 0);
+
+		/* Only lower priority if we didn't make progress. */
+		if (count == loopcount) {
+			priority--;
+		}
+		loopcount = count;
+	} while (priority > 0);
 done:
 	unlock_kernel();
 
-	/* Return success if we freed a page. */
-	return priority > 0;
+	/* Return success if we have enough free memory or we freed a page. */
+	if (nr_free_pages > freepages.low)
+		return 1;
+
+	return count < SWAP_CLUSTER_MAX;
 }
 
 /*
@@ -505,22 +506,23 @@
 		 * the processes needing more memory will wake us
 		 * up on a more timely basis.
 		 */
-		interruptible_sleep_on(&kswapd_wait);
+		interruptible_sleep_on_timeout(&kswapd_wait, HZ);
 
-		/*
-		 * In 2.2.x-bigmem kswapd is critical to provide GFP_ATOMIC
-		 * allocations (not GFP_BIGMEM ones).
-		 */
-		while (nr_free_pages - nr_free_bigpages < freepages.high)
-		{
-			if (try_to_free_pages(GFP_KSWAPD))
+		if (nr_free_pages < freepages.low) {
+			while (nr_free_pages < freepages.high)
 			{
-				if (tsk->need_resched)
-					schedule();
-				continue;
+				if (try_to_free_pages(GFP_KSWAPD))
+				{
+					if (tsk->need_resched)
+						schedule();
+					continue;
+				}
+				tsk->state = TASK_INTERRUPTIBLE;
+				schedule_timeout(10*HZ);
 			}
-			tsk->state = TASK_INTERRUPTIBLE;
-			schedule_timeout(10*HZ);
+		} else if (nr_free_pages < freepages.high) {
+			/* Background scanning. */
+			try_to_free_pages(GFP_KSWAPD);
 		}
 	}
 }

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

             reply	other threads:[~2000-11-19  0:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-19  0:04 Rik van Riel [this message]
2000-11-19  8:01 ` [PATCH] blindingly stupid 2.2 VM bug Ville Herva
2000-11-20 13:38   ` Rik van Riel
2000-11-24 23:28     ` Chip Salzenberg
2000-11-25 13:57       ` Andrea Arcangeli
2000-11-25 17:06         ` Rik van Riel
2000-11-28 23:02         ` John Kennedy
2000-11-28 23:20           ` Andrea Arcangeli
2000-11-28 23:36             ` John Kennedy
2000-11-29  0:04               ` Andrea Arcangeli
2000-11-29  0:35                 ` John Kennedy
2000-11-30 11:47                   ` Stephen C. Tweedie

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.21.0011182201250.11745-100000@duckman.distro.conectiva \
    --to=riel@conectiva.com.br \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /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;
as well as URLs for NNTP newsgroup(s).