linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: akpm@osdl.org
Cc: Hugh Dickins <hugh@veritas.com>,
	Mike Kravetz <kravetz@us.ibm.com>,
	linux-kernel@vger.kernel.org, Dave Hansen <haveblue@us.ibm.com>,
	linux-mm@kvack.org, torvalds@osdl.org,
	Christoph Lameter <clameter@sgi.com>,
	Hirokazu Takahashi <taka@valinux.co.jp>,
	Magnus Damm <magnus.damm@gmail.com>, Paul Jackson <pj@sgi.com>,
	Marcelo Tosatti <marcelo.tosatti@cyclades.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: [PATCH 2/7] Direct Migration V1: PageSwapCache checks
Date: Fri, 4 Nov 2005 15:37:22 -0800 (PST)	[thread overview]
Message-ID: <20051104233722.5459.68575.sendpatchset@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <20051104233712.5459.94627.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.14-rc5-mm1/mm/memory.c
===================================================================
--- linux-2.6.14-rc5-mm1.orig/mm/memory.c	2005-10-24 10:27:12.000000000 -0700
+++ linux-2.6.14-rc5-mm1/mm/memory.c	2005-10-28 16:09:11.000000000 -0700
@@ -1665,6 +1665,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);
@@ -1688,6 +1689,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.14-rc5-mm1/mm/shmem.c
===================================================================
--- linux-2.6.14-rc5-mm1.orig/mm/shmem.c	2005-10-24 10:27:12.000000000 -0700
+++ linux-2.6.14-rc5-mm1/mm/shmem.c	2005-10-28 16:08:20.000000000 -0700
@@ -1013,6 +1013,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.14-rc5-mm1/mm/swapfile.c
===================================================================
--- linux-2.6.14-rc5-mm1.orig/mm/swapfile.c	2005-10-24 10:27:36.000000000 -0700
+++ linux-2.6.14-rc5-mm1/mm/swapfile.c	2005-10-28 16:08:20.000000000 -0700
@@ -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);
 
 		/*

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2005-11-04 23:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-04 23:37 [PATCH 0/7] Direct Migration V1: Overview Christoph Lameter
2005-11-04 23:37 ` [PATCH 1/7] Direct Migration V1: CONFIG_MIGRATION for swap migration Christoph Lameter
2005-11-04 23:37 ` Christoph Lameter [this message]
2005-11-04 23:37 ` [PATCH 3/7] Direct Migration V1: migrate_pages() extension for direct migration Christoph Lameter
2005-11-04 23:37 ` [PATCH 4/7] Direct Migration V1: remove_from_swap() to remove swap ptes Christoph Lameter
2005-11-04 23:37 ` [PATCH 5/7] Direct Migration V1: upgrade MPOL_MF_MOVE and sys_migrate_pages() Christoph Lameter
2005-11-04 23:37 ` [PATCH 6/7] Direct Migration V1: Avoid writeback using page_migrate() method Christoph Lameter
2005-11-04 23:37 ` [PATCH 7/7] Direct Migration V1: Add gfp_t to add_to_swap() to avoid atomic allocs 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=20051104233722.5459.68575.sendpatchset@schroedinger.engr.sgi.com \
    --to=clameter@sgi.com \
    --cc=akpm@osdl.org \
    --cc=haveblue@us.ibm.com \
    --cc=hugh@veritas.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kravetz@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=magnus.damm@gmail.com \
    --cc=marcelo.tosatti@cyclades.com \
    --cc=pj@sgi.com \
    --cc=taka@valinux.co.jp \
    --cc=torvalds@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox