All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, lhms-devel@lists.sourceforge.net,
	Cliff Wickman <cpw@sgi.com>, Christoph Lameter <clameter@sgi.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: [PATCH 1/5] Direct Migration V6: PageSwapCache checks
Date: Wed, 30 Nov 2005 09:11:02 -0800 (PST)	[thread overview]
Message-ID: <20051130171102.19405.62052.sendpatchset@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <20051130171056.19405.95644.sendpatchset@schroedinger.engr.sgi.com>

Check for PageSwapCache after looking up and locking a swap page.

The page migration code may change a swap pte to point to a different page
under lock_page().

If that happens then the vm must retry the lookup operation in the swap
space to find the correct page number. There are a couple of locations
in the VM where a lock_page() is done on a swap page. In these locations
we need to check afterwards if the page was migrated. If the page was migrated
then the old page that was looked up before was freed and no longer has the
PageSwapCache bit set.

Signed-off-by: Hirokazu Takahashi <taka@valinux.co.jp>
Signed-off-by: Dave Hansen <haveblue@us.ibm.com>
Signed-off-by: Christoph Lameter <clameter@@sgi.com>

Index: linux-2.6.15-rc3-mm1/mm/memory.c
===================================================================
--- linux-2.6.15-rc3-mm1.orig/mm/memory.c	2005-11-30 08:46:40.000000000 -0800
+++ linux-2.6.15-rc3-mm1/mm/memory.c	2005-11-30 08:46:44.000000000 -0800
@@ -1882,6 +1882,7 @@ static int do_swap_page(struct mm_struct
 		goto out;
 
 	entry = pte_to_swp_entry(orig_pte);
+again:
 	page = lookup_swap_cache(entry);
 	if (!page) {
  		swapin_readahead(entry, address, vma);
@@ -1905,6 +1906,12 @@ static int do_swap_page(struct mm_struct
 
 	mark_page_accessed(page);
 	lock_page(page);
+	if (!PageSwapCache(page)) {
+		/* Page migration has occured */
+		unlock_page(page);
+		page_cache_release(page);
+		goto again;
+	}
 
 	/*
 	 * Back out if somebody else already faulted in this pte.
Index: linux-2.6.15-rc3-mm1/mm/shmem.c
===================================================================
--- linux-2.6.15-rc3-mm1.orig/mm/shmem.c	2005-11-30 08:46:40.000000000 -0800
+++ linux-2.6.15-rc3-mm1/mm/shmem.c	2005-11-30 08:46:44.000000000 -0800
@@ -1028,6 +1028,14 @@ repeat:
 			page_cache_release(swappage);
 			goto repeat;
 		}
+		if (!PageSwapCache(swappage)) {
+			/* Page migration has occured */
+			shmem_swp_unmap(entry);
+			spin_unlock(&info->lock);
+			unlock_page(swappage);
+			page_cache_release(swappage);
+			goto repeat;
+		}
 		if (PageWriteback(swappage)) {
 			shmem_swp_unmap(entry);
 			spin_unlock(&info->lock);
Index: linux-2.6.15-rc3-mm1/mm/swapfile.c
===================================================================
--- linux-2.6.15-rc3-mm1.orig/mm/swapfile.c	2005-11-28 19:51:27.000000000 -0800
+++ linux-2.6.15-rc3-mm1/mm/swapfile.c	2005-11-30 08:46:44.000000000 -0800
@@ -624,6 +624,7 @@ static int try_to_unuse(unsigned int typ
 		 */
 		swap_map = &si->swap_map[i];
 		entry = swp_entry(type, i);
+again:
 		page = read_swap_cache_async(entry, NULL, 0);
 		if (!page) {
 			/*
@@ -658,6 +659,12 @@ static int try_to_unuse(unsigned int typ
 		wait_on_page_locked(page);
 		wait_on_page_writeback(page);
 		lock_page(page);
+		if (!PageSwapCache(page)) {
+			/* Page migration has occured */
+			unlock_page(page);
+			page_cache_release(page);
+			goto again;
+		}
 		wait_on_page_writeback(page);
 
 		/*

  reply	other threads:[~2005-11-30 17:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-30 17:10 [PATCH 0/5] Direct Migration V6: Overview Christoph Lameter
2005-11-30 17:11 ` Christoph Lameter [this message]
2005-11-30 17:11 ` [PATCH 2/5] Direct Migration V6: migrate_pages() extension Christoph Lameter
2005-11-30 17:11 ` [PATCH 3/5] Direct Migration V6: remove_from_swap() to remove swap ptes Christoph Lameter
2005-11-30 17:11 ` [PATCH 4/5] Direct Migration V6: upgrade MPOL_MF_MOVE and sys_migrate_pages() Christoph Lameter
2005-11-30 17:11 ` [PATCH 5/5] Direct Migration V6: Avoid writeback / page_migrate() method Christoph Lameter
2005-11-30 23:52 ` [PATCH 0/5] Direct Migration V6: Overview KAMEZAWA Hiroyuki
2005-12-01  0:05   ` Christoph Lameter
  -- strict thread matches above, loose matches on Subject: below --
2005-12-05 19:50 Christoph Lameter
2005-12-05 19:50 ` [PATCH 1/5] Direct Migration V6: PageSwapCache checks Christoph Lameter

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=20051130171102.19405.62052.sendpatchset@schroedinger.engr.sgi.com \
    --to=clameter@sgi.com \
    --cc=akpm@osdl.org \
    --cc=cpw@sgi.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=lhms-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.