linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] small thrashing improvement
@ 1998-02-26 15:18 Rik van Riel
  0 siblings, 0 replies; only message in thread
From: Rik van Riel @ 1998-02-26 15:18 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Stephen C. Tweedie, linux-mm

Hi Linus and Stephen,

here's a (very small) patch that improves the
responsiveness of interactive programs when the
system is thrashing.

Basically, it just adds the page aging capability
to the page cache (but _not_ to the buffer cache, since
we really want to get rid of buffers when memory is
tight).

I think it's trivial enough to go into 2.1.89, but
that's just MHO...

Rik.
+-----------------------------+------------------------------+
| For Linux mm-patches, go to | "I'm busy managing memory.." |
| my homepage (via LinuxHQ).  | H.H.vanRiel@fys.ruu.nl       |
| ...submissions welcome...   | http://www.fys.ruu.nl/~riel/ |
+-----------------------------+------------------------------+
               ____________
-------------->| cut here |<--------------------
               `~~~~~~~~~~'

--- linux2188orig/mm/filemap.c	Wed Feb 25 16:40:55 1998
+++ linux-2.1.88/mm/filemap.c	Thu Feb 26 15:43:16 1998
@@ -25,6 +25,7 @@
 #include <linux/smp.h>
 #include <linux/smp_lock.h>
 #include <linux/blkdev.h>
+#include <linux/swapctl.h>
 
 #include <asm/system.h>
 #include <asm/pgtable.h>
@@ -158,12 +159,15 @@
 
 		switch (atomic_read(&page->count)) {
 			case 1:
-				/* If it has been referenced recently, don't free it */
-				if (test_and_clear_bit(PG_referenced, &page->flags))
-					break;
-
 				/* is it a page cache page? */
 				if (page->inode) {
+					if (test_and_clear_bit(PG_referenced, &page->flags)) {
+						touch_page(page);
+						break;
+					}
+					age_page(page);
+					if (page->age)
+						break;
 					if (page->inode == &swapper_inode)
 						panic ("Shrinking a swap cache page");
 					remove_page_from_hash_queue(page);
@@ -171,6 +175,10 @@
 					__free_page(page);
 					return 1;
 				}
+
+				/* If it has been referenced recently, don't free it */
+				if (test_and_clear_bit(PG_referenced, &page->flags))
+					break;
 
 				/* is it a buffer cache page? */
 				if ((gfp_mask & __GFP_IO) && bh && try_to_free_buffer(bh, &bh, 6))

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

only message in thread, other threads:[~1998-02-26 15:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-02-26 15:18 [PATCH] small thrashing improvement 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