linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: akpm@osdl.org
Cc: linux-mm@kvack.org, Hugh Dickins <hugh@veritas.com>,
	Lee Schermerhorn <lee.schermerhorn@hp.com>,
	Christoph Lameter <clameter@sgi.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: [PATCH 2/3] more page migration: move common code to migrate pages()
Date: Fri, 28 Apr 2006 14:24:39 -0700 (PDT)	[thread overview]
Message-ID: <20060428212439.2737.94818.sendpatchset@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <20060428212434.2737.43187.sendpatchset@schroedinger.engr.sgi.com>

more page migration: move common code from migration functions to migrate pages()

All migration functions start by unmapping ptes and thereby potentially
creating migration ptes. They all end by replacing the migration ptes with
real ones.

So extract the common code and put it into migrate_pages().

Signed-off-by: Christoph Lameter <clameter@sgi.com>

Index: linux-2.6.17-rc2-mm1/mm/migrate.c
===================================================================
--- linux-2.6.17-rc2-mm1.orig/mm/migrate.c	2006-04-28 11:21:51.877154899 -0700
+++ linux-2.6.17-rc2-mm1/mm/migrate.c	2006-04-28 13:29:36.577252635 -0700
@@ -258,17 +258,11 @@
 {
 	struct page **radix_pointer;
 
-	/*
-	 * Retry if we were unable to remove all mappings.
-	 */
-	if (page_mapcount(page))
-		return -EAGAIN;
-
 	if (!mapping) {
 		/*
 		 * Anonymous page without swap mapping.
 		 */
-		if (page_count(page) != 1)
+		if (page_count(page) != 1 || !page->mapping)
 			return -EAGAIN;
 
 		return 0;
@@ -371,21 +365,12 @@
 
 	BUG_ON(PageWriteback(page));	/* Writeback must be complete */
 
-	if (try_to_unmap(page, 1) == SWAP_FAIL) {
-		remove_migration_ptes(page, page);
-		return -EPERM;
-	}
-
 	rc = migrate_page_move_mapping(mapping, newpage, page);
 
-	if (rc) {
-		remove_migration_ptes(page, page);
-		return rc;
-	}
+	if (!rc)
+		migrate_page_copy(newpage, page);
 
-	migrate_page_copy(newpage, page);
-	remove_migration_ptes(page, newpage);
-	return 0;
+	return rc;
 }
 EXPORT_SYMBOL(migrate_page);
 
@@ -403,9 +388,6 @@
 	if (!page_has_buffers(page))
 		return migrate_page(mapping, newpage, page);
 
-	if (try_to_unmap(page, 1) == SWAP_FAIL)
-		return -EPERM;
-
 	head = page_buffers(page);
 
 	rc = migrate_page_move_mapping(mapping, newpage, page);
@@ -455,10 +437,6 @@
 {
 	int rc;
 
-	if (try_to_unmap(page, 1) == SWAP_FAIL)
-		/* A vma has VM_LOCKED set -> permanent failure */
-		return -EPERM;
-
 	/*
 	 * Removing the ptes may have dirtied the page
 	 */
@@ -590,6 +568,21 @@
 		else if (PageWriteback(page))
 				goto unlock_page;
 
+		/*
+		 * Establish migration entries or unmap file ptes.
+		 */
+		rc = -EPERM;
+		if (try_to_unmap(page, 1) == SWAP_FAIL)
+			/* A vma has VM_LOCKED set -> permanent failure */
+			goto remove_migentry;
+
+		/*
+		 * Retry if we were unable to remove all mappings.
+		 */
+		rc = -EAGAIN;
+		if (page_mapcount(page))
+			goto remove_migentry;
+
 		lock_page(newpage);
 		/* Prepare mapping for the new page.*/
 		newpage->index = page->index;
@@ -609,7 +602,13 @@
 		else
 			rc = fallback_migrate_page(mapping, newpage, page);
 
+		if (rc == 0)
+			remove_migration_ptes(page, newpage);
 		unlock_page(newpage);
+
+remove_migentry:
+		if (rc)
+			remove_migration_ptes(page, page);
 unlock_page:
 		unlock_page(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>

  reply	other threads:[~2006-04-28 21:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-28 21:24 [PATCH 1/3] more page migration: Do not dec/inc rss counters Christoph Lameter
2006-04-28 21:24 ` Christoph Lameter [this message]
2006-04-28 21:24 ` [PATCH 3/3] more page migration: migration entries for file backed pages 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=20060428212439.2737.94818.sendpatchset@schroedinger.engr.sgi.com \
    --to=clameter@sgi.com \
    --cc=akpm@osdl.org \
    --cc=hugh@veritas.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=lee.schermerhorn@hp.com \
    --cc=linux-mm@kvack.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;
as well as URLs for NNTP newsgroup(s).