]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - mm/swap.c
vmscan: free swap space on swap-in/activation
[linux-2.6-omap-h63xx.git] / mm / swap.c
index e3045040dc3ec26eea087d065855a18aea429838..88a39487267769d83f281664d83e87c4e83859f1 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -427,6 +427,30 @@ void pagevec_strip(struct pagevec *pvec)
        }
 }
 
+/**
+ * pagevec_swap_free - try to free swap space from the pages in a pagevec
+ * @pvec: pagevec with swapcache pages to free the swap space of
+ *
+ * The caller needs to hold an extra reference to each page and
+ * not hold the page lock on the pages.  This function uses a
+ * trylock on the page lock so it may not always free the swap
+ * space associated with a page.
+ */
+void pagevec_swap_free(struct pagevec *pvec)
+{
+       int i;
+
+       for (i = 0; i < pagevec_count(pvec); i++) {
+               struct page *page = pvec->pages[i];
+
+               if (PageSwapCache(page) && trylock_page(page)) {
+                       if (PageSwapCache(page))
+                               remove_exclusive_swap_page_ref(page);
+                       unlock_page(page);
+               }
+       }
+}
+
 /**
  * pagevec_lookup - gang pagecache lookup
  * @pvec:      Where the resulting pages are placed