lkml.org 
[lkml]   [2001]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Reap dead swap cache earlier v2

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;
}

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

\
 
 \ /
  Last update: 2005-03-22 12:54    [W:0.050 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site