linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] -ac21 don't set referenced bit
@ 2000-06-19 15:36 Rik van Riel
  2000-06-19 16:22 ` Andrea Arcangeli
  0 siblings, 1 reply; 6+ messages in thread
From: Rik van Riel @ 2000-06-19 15:36 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linus Torvalds, linux-mm, los

Hi,

the patch below, against -ac21, does two things:

1) do not set the referenced bit when we add a page to
   one of the caches ... this allows us to distinguish
   between pages which are used again and pages which
   aren't   [keeps performance nice in the presence of
   streaming IO?]

2) in do_try_to_free_pages, if we make progress on a
   priority level, do not decrease priority when we loop
   again ... this should allow us to  a) free more pages
   since we can keep looping back as long as progress is
   being made and  b) maybe keep a better balance between
   shrink_mmap and swap_out since we have a better chance
   to never reach the "gimme memory now or I'll rape your
   wife and kill your children" level
   [and we don't want to get there since arriving at that
   priority level means we'll be doing worse page aging
   and forcing the issue ... potentially making things worse
   for the next time]

With this patch I'm seeing higher application performance and
lower kswapd cpu usage...

regards,

Rik
--
The Internet is not a network of computers. It is a network
of people. That is its real strength.

Wanna talk about the kernel?  irc.openprojects.net / #kernelnewbies
http://www.conectiva.com/		http://www.surriel.com/



--- mm/filemap.c.orig	Mon Jun 19 11:32:32 2000
+++ mm/filemap.c	Mon Jun 19 11:33:21 2000
@@ -564,7 +564,7 @@
 
 /*
  * This adds a page to the page cache, starting out as locked,
- * owned by us, referenced, but not uptodate and with no errors.
+ * owned by us, but not uptodate and with no errors.
  */
 static inline void __add_to_page_cache(struct page * page,
 	struct address_space *mapping, unsigned long offset,
@@ -576,8 +576,8 @@
 	if (PageLocked(page))
 		BUG();
 
-	flags = page->flags & ~((1 << PG_uptodate) | (1 << PG_error) | (1 << PG_dirty));
-	page->flags = flags | (1 << PG_locked) | (1 << PG_referenced);
+	flags = page->flags & ~((1 << PG_uptodate) | (1 << PG_error));
+	page->flags = flags | (1 << PG_locked);
 	page_cache_get(page);
 	page->index = offset;
 	add_page_to_inode_queue(mapping, page);
--- mm/swap_state.c.orig	Mon Jun 19 11:32:32 2000
+++ mm/swap_state.c	Mon Jun 19 11:33:59 2000
@@ -58,8 +58,8 @@
 		BUG();
 	if (page->mapping)
 		BUG();
-	flags = page->flags & ~((1 << PG_error) | (1 << PG_dirty));
-	page->flags = flags | (1 << PG_referenced) | (1 << PG_uptodate);
+	flags = page->flags & ~(1 << PG_error);
+	page->flags = flags | (1 << PG_uptodate);
 	add_to_page_cache_locked(page, &swapper_space, entry.val);
 }
 
--- mm/vmscan.c.orig	Mon Jun 19 11:32:32 2000
+++ mm/vmscan.c	Mon Jun 19 11:47:10 2000
@@ -444,6 +444,7 @@
 	int priority;
 	int count = FREE_COUNT;
 	int swap_count = 0;
+	int made_progress = 0;
 	int ret = 0;
 
 	/* Always trim SLAB caches when memory gets low. */
@@ -452,7 +453,7 @@
 	priority = 64;
 	do {
 		while (shrink_mmap(priority, gfp_mask)) {
-			ret = 1;
+			made_progress = 1;
 			if (!--count)
 				goto done;
 		}
@@ -468,11 +469,11 @@
 			count -= shrink_dcache_memory(priority, gfp_mask);
 			count -= shrink_icache_memory(priority, gfp_mask);
 			if (count <= 0) {
-				ret = 1;
+				made_progress = 1;
 				goto done;
 			}
 			while (shm_swap(priority, gfp_mask)) {
-				ret = 1;
+				made_progress = 1;
 				if (!--count)
 					goto done;
 			}
@@ -493,11 +494,25 @@
 		 */
 		swap_count += count;
 		while (swap_out(priority, gfp_mask)) {
+			made_progress = 1;
 			if (--swap_count < 0)
 				break;
 		}
 
-	} while (--priority >= 0);
+		/*
+		 * If we made progress at the current priority, the next
+		 * loop will also be done at this priority level. There's
+		 * absolutely no reason to drop to a lower priority and
+		 * potentially upset the balance between shrink_mmap and
+		 * swap_out.
+		 */
+		if (made_progress) {
+			made_progress = 0;
+			ret = 1;
+		} else {
+			priority--;
+		}
+	} while (priority >= 0);
 
 	/* Always end on a shrink_mmap.. */
 	while (shrink_mmap(0, gfp_mask)) {


--
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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-06-19 18:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-19 15:36 [PATCH] -ac21 don't set referenced bit Rik van Riel
2000-06-19 16:22 ` Andrea Arcangeli
2000-06-19 17:00   ` Rik van Riel
2000-06-19 17:10     ` Andrea Arcangeli
2000-06-19 17:51       ` Rik van Riel
2000-06-19 18:06         ` Andrea Arcangeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox