linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Reap dead swap cache earlier v2
@ 2001-06-06 20:07 Marcelo Tosatti
  2001-06-07 14:47 ` John Stoffel
  2001-06-07 19:07 ` Jonathan Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Marcelo Tosatti @ 2001-06-06 20:07 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: lkml, linux-mm


Hi, 

As suggested by Linus, I've cleaned the reapswap code to be contained
inside an inline function. (yes, the if statement is really ugly) 

Tested and against 2.4.6pre1. 



--- linux.orig/mm/vmscan.c	Wed Jun  6 18:16:45 2001
+++ linux/mm/vmscan.c	Wed Jun  6 18:28:26 2001
@@ -407,6 +407,27 @@
 	memory_pressure++;
 	return page;
 }
+/*
+ * Check for dead swap cache pages and clean them, forcing 
+ * those pages to be freed earlier.
+ */
+static inline int clean_dead_swap_page (struct page* page)
+{
+	int ret = 0;
+	if (!TryLockPage (page)) { 
+		if (PageSwapCache(page) && PageDirty(page) &&
+				(page_count(page) - !!page->buffers) == 1 &&
+				swap_count(page) == 1) { 
+			ClearPageDirty(page);
+			ClearPageReferenced(page);
+			page->age = 0;
+			ret = 1;
+		}
+		UnlockPage(page);
+	}
+	return ret;
+}
+
 
 /**
  * page_launder - clean dirty inactive pages, move to inactive_clean list
@@ -456,6 +477,12 @@
 			continue;
 		}
 
+		/*
+		 * Check for dead swap cache pages 
+		 * before doing any other checks.
+		 */
+		clean_dead_swap_page(page);
+			
 		/* Page is or was in use?  Move it to the active list. */
 		if (PageReferenced(page) || page->age > 0 ||
 				page->zone->free_pages > page->zone->pages_high ||
@@ -666,6 +693,15 @@
 			printk("VM: refill_inactive, wrong page on list.\n");
 			list_del(page_lru);
 			nr_active_pages--;
+			continue;
+		}
+		
+		/*
+		 * Special case for dead swap cache pages.
+		 */
+		if (clean_dead_swap_page(page)) {
+			deactivate_page_nolock(page);
+			nr_deactivated++;
 			continue;
 		}
 


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

end of thread, other threads:[~2001-06-07 19:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-06 20:07 [PATCH] Reap dead swap cache earlier v2 Marcelo Tosatti
2001-06-07 14:47 ` John Stoffel
2001-06-07 15:44   ` Hugh Dickins
2001-06-07 19:07 ` Jonathan Morton
2001-06-07 17:38   ` Marcelo Tosatti
2001-06-07 19:31   ` Jonathan Morton

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).