linux-mm.kvack.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: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] page_launder improvement for 2.4.1-ac19
Date: Tue, 20 Feb 2001 15:52:56 -0300 (BRST)	[thread overview]
Message-ID: <Pine.LNX.4.21.0102201547400.3674-100000@duckman.distro.conectiva> (raw)

Hi Alan,

the following patch makes kswapd always flush the right amount
of pages in page_launder()  (ie. the number of pages we need
to flush in order to work away the free shortage, minus the number
of swapouts already in flight).

This makes the system react better under write loads, because
user processes will have to go into try_to_free_pages() a lot
less themselves...

regards,

Rik
--
Linux MM bugzilla: http://linux-mm.org/bugzilla.shtml

Virtual memory is like a game you can't win;
However, without VM there's truly nothing to lose...

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



--- linux-2.4.1-ac19/mm/vmscan.c.orig	Tue Feb 20 15:30:44 2001
+++ linux-2.4.1-ac19/mm/vmscan.c	Tue Feb 20 15:31:24 2001
@@ -413,7 +413,7 @@
  * This code is heavily inspired by the FreeBSD source code. Thanks
  * go out to Matthew Dillon.
  *
- * XXX: restrict number of pageouts in flight...
+ * XXX: restrict number of pageouts in flight by ->writepage...
  */
 #define MAX_LAUNDER 		(1 << page_cluster)
 int page_launder(int gfp_mask, int user)
@@ -514,7 +514,10 @@
 			spin_unlock(&pagemap_lru_lock);
 
 			writepage(page);
-			flushed_pages++;
+			/* XXX: all ->writepage()s should use nr_async_pages */
+			if (!PageSwapCache(page))
+				flushed_pages++;
+			maxlaunder--;
 			page_cache_release(page);
 
 			/* And re-start the thing.. */
@@ -563,7 +566,8 @@
 			/* The buffers were not freed. */
 			if (!clearedbuf) {
 				add_page_to_inactive_dirty_list(page);
-				flushed_pages++;
+				if (wait)
+					flushed_pages++;
 
 			/* The page was only in the buffer cache. */
 			} else if (!page->mapping) {
@@ -636,14 +640,16 @@
 		 * with the paging load in the system and doesn't have
 		 * the IO storm problem, so it just flushes all pages
 		 * needed to fix the free shortage.
-		 *
-		 * XXX: keep track of nr_async_pages like the old swap
-		 * code did?
 		 */
-		if (user)
+		maxlaunder = shortage;
+		maxlaunder -= flushed_pages;
+		maxlaunder -= atomic_read(&nr_async_pages);
+	
+		if (maxlaunder <= 0)
+			goto out;
+
+		if (user && maxlaunder > MAX_LAUNDER)
 			maxlaunder = MAX_LAUNDER;
-		else
-			maxlaunder = shortage;
 
 		/*
 		 * If we are called by a user program, we need to free
@@ -667,6 +673,7 @@
 	/*
 	 * Return the amount of pages we freed or made freeable.
 	 */
+out:
 	return freed_pages + flushed_pages;
 }
 
--- linux-2.4.1-ac19/mm/page_io.c.orig	Tue Feb 20 15:31:51 2001
+++ linux-2.4.1-ac19/mm/page_io.c	Tue Feb 20 15:32:21 2001
@@ -69,7 +69,7 @@
 	} else {
 		return 0;
 	}
- 	if (!wait) {
+ 	if (!wait && rw == WRITE) {
  		SetPageDecrAfter(page);
  		atomic_inc(&nr_async_pages);
  	}

--
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:[~2001-02-20 18:52 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.21.0102201547400.3674-100000@duckman.distro.conectiva \
    --to=riel@conectiva.com.br \
    --cc=alan@lxorguk.ukuu.org.uk \
    --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