LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: Rik van Riel <riel@redhat.com>
Cc: Christoph Lameter <clameter@sgi.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>, Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] free swap space when (re)activating page
Date: Tue, 20 Feb 2007 14:54:11 -0500	[thread overview]
Message-ID: <45DB51E3.8090909@redhat.com> (raw)
In-Reply-To: <45DB4C87.6050809@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 284 bytes --]

Rik van Riel wrote:

> ... because I think this is what my patch does :)

Never mind, I see it now.

The attached patch should be correct.

Btw, why do we not call pagevec_strip on the pages on l_active?
I assume we want to reclaim their buffer heads, too...

-- 
All Rights Reversed

[-- Attachment #2: linux-2.6-swapfree.patch --]
[-- Type: text/x-patch, Size: 2259 bytes --]

--- linux-2.6.20.noarch/mm/vmscan.c.swapfree	2007-02-20 06:44:13.000000000 -0500
+++ linux-2.6.20.noarch/mm/vmscan.c	2007-02-20 06:54:10.000000000 -0500
@@ -587,6 +587,9 @@ free_it:
 		continue;
 
 activate_locked:
+		/* Not a candidate for swapping, so reclaim swap space. */
+		if (PageSwapCache(page) && vm_swap_full())
+			remove_exclusive_swap_page(page);
 		SetPageActive(page);
 		pgactivate++;
 keep_locked:
@@ -889,6 +892,8 @@ force_reclaim_mapped:
 			__mod_zone_page_state(zone, NR_ACTIVE, pgmoved);
 			pgmoved = 0;
 			spin_unlock_irq(&zone->lru_lock);
+			if (vm_swap_full())
+				pagevec_swap_free(&pvec);
 			__pagevec_release(&pvec);
 			spin_lock_irq(&zone->lru_lock);
 		}
@@ -899,6 +904,8 @@ force_reclaim_mapped:
 	__count_vm_events(PGDEACTIVATE, pgdeactivate);
 	spin_unlock_irq(&zone->lru_lock);
 
+	if (vm_swap_full())
+		pagevec_swap_free(&pvec);
 	pagevec_release(&pvec);
 }
 
--- linux-2.6.20.noarch/mm/swap.c.swapfree	2007-02-04 13:44:54.000000000 -0500
+++ linux-2.6.20.noarch/mm/swap.c	2007-02-20 06:44:17.000000000 -0500
@@ -420,6 +420,26 @@ void pagevec_strip(struct pagevec *pvec)
 	}
 }
 
+/*
+ * Try to free swap space from the pages in a pagevec
+ */
+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) && !TestSetPageLocked(page)) {
+			if (PageSwapCache(page))
+				remove_exclusive_swap_page(page);
+			unlock_page(page);
+			if (printk_ratelimit())
+				printk("kswapd freed a swap space\n");
+		}
+	}
+}
+
 /**
  * pagevec_lookup - gang pagecache lookup
  * @pvec:	Where the resulting pages are placed
--- linux-2.6.20.noarch/include/linux/pagevec.h.swapfree	2007-02-04 13:44:54.000000000 -0500
+++ linux-2.6.20.noarch/include/linux/pagevec.h	2007-02-20 06:44:17.000000000 -0500
@@ -26,6 +26,7 @@ void __pagevec_free(struct pagevec *pvec
 void __pagevec_lru_add(struct pagevec *pvec);
 void __pagevec_lru_add_active(struct pagevec *pvec);
 void pagevec_strip(struct pagevec *pvec);
+void pagevec_swap_free(struct pagevec *pvec);
 unsigned pagevec_lookup(struct pagevec *pvec, struct address_space *mapping,
 		pgoff_t start, unsigned nr_pages);
 unsigned pagevec_lookup_tag(struct pagevec *pvec,

  parent reply	other threads:[~2007-02-20 19:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 22:46 Rik van Riel
2007-02-20  4:53 ` Christoph Lameter
2007-02-20 13:28   ` Rik van Riel
2007-02-20 16:37     ` Christoph Lameter
2007-02-20 16:46       ` Rik van Riel
2007-02-20 18:20         ` Christoph Lameter
2007-02-20 19:31           ` Rik van Riel
2007-02-20 19:42             ` Christoph Lameter
2007-02-20 19:54             ` Rik van Riel [this message]
2007-02-20 20:26               ` Christoph Lameter
2007-02-20 20:57               ` Christoph Lameter
2007-02-20 19:00 ` William Lee Irwin III
2007-02-21 15:09 Al Boldi
     [not found] <7Pk3X-bD-17@gated-at.bofh.it>
     [not found] ` <7QvgM-3aK-3@gated-at.bofh.it>
     [not found]   ` <7QDeB-7KY-11@gated-at.bofh.it>
     [not found]     ` <7QGc7-3ZB-13@gated-at.bofh.it>
     [not found]       ` <7QGlP-4e1-11@gated-at.bofh.it>
     [not found]         ` <7QHUO-6RS-5@gated-at.bofh.it>
     [not found]           ` <7QJ9Y-mo-1@gated-at.bofh.it>
     [not found]             ` <7QJk7-zW-51@gated-at.bofh.it>
2007-02-23  1:44               ` Bodo Eggert
2007-02-23  3:34                 ` Rik van Riel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45DB51E3.8090909@redhat.com \
    --to=riel@redhat.com \
    --cc=akpm@osdl.org \
    --cc=clameter@sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --subject='Re: [PATCH] free swap space when (re)activating page' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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