All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
To: linux-kernel <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>, Andrew Morton <akpm@osdl.org>
Subject: [PATCH 2.6.18-rc6.mm2] revert migrate_move_mapping to use direct radix tree slot update
Date: Wed, 13 Sep 2006 15:09:34 -0400	[thread overview]
Message-ID: <1158174574.5328.37.camel@localhost> (raw)



Now that the problem with the rcu radix tree replace slot function has
been fixed, we can, if Christoph agrees:

Revert migrate_page_move_mapping() to use direct radix tree
slot replacement.  Fix up variable types to match modified
interfaces to radix_tree_{deref|replace}_slot().


Signed-off-by:  Lee Schermerhorn <lee.schermerhorn@hp.com>

 mm/migrate.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

Index: linux-2.6.18-rc6-mm2/mm/migrate.c
===================================================================
--- linux-2.6.18-rc6-mm2.orig/mm/migrate.c	2006-09-13 11:39:14.000000000 -0400
+++ linux-2.6.18-rc6-mm2/mm/migrate.c	2006-09-13 11:42:36.000000000 -0400
@@ -294,8 +294,7 @@ out:
 static int migrate_page_move_mapping(struct address_space *mapping,
 		struct page *newpage, struct page *page)
 {
-	struct page *current_page;
-	long index;
+	void **pslot;
 
 	if (!mapping) {
 		/* Anonymous page */
@@ -306,14 +305,11 @@ static int migrate_page_move_mapping(str
 
 	write_lock_irq(&mapping->tree_lock);
 
-	index = page_index(page);
-
-	current_page = (struct page *)radix_tree_lookup(
-						&mapping->page_tree,
-						index);
+	pslot = radix_tree_lookup_slot(&mapping->page_tree,
+ 					page_index(page));
 
 	if (page_count(page) != 2 + !!PagePrivate(page) ||
-			current_page != page) {
+			(struct page *)radix_tree_deref_slot(pslot) != page) {
 		write_unlock_irq(&mapping->tree_lock);
 		return -EAGAIN;
 	}
@@ -321,7 +317,7 @@ static int migrate_page_move_mapping(str
 	/*
 	 * Now we know that no one else is looking at the page.
 	 */
-	get_page(newpage);
+	get_page(newpage);	/* add cache reference */
 #ifdef CONFIG_SWAP
 	if (PageSwapCache(page)) {
 		SetPageSwapCache(newpage);
@@ -329,9 +325,14 @@ static int migrate_page_move_mapping(str
 	}
 #endif
 
-	radix_tree_delete(&mapping->page_tree, index);
-	radix_tree_insert(&mapping->page_tree, index, newpage);
+	radix_tree_replace_slot(pslot, newpage);
+
+	/*
+	 * Drop cache reference from old page.
+	 * We know this isn't the last reference.
+	 */
 	__put_page(page);
+
 	write_unlock_irq(&mapping->tree_lock);
 
 	return 0;



WARNING: multiple messages have this Message-ID (diff)
From: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
To: linux-kernel <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>, Andrew Morton <akpm@osdl.org>
Subject: [PATCH 2.6.18-rc6.mm2] revert migrate_move_mapping to use direct radix tree slot update
Date: Wed, 13 Sep 2006 15:09:34 -0400	[thread overview]
Message-ID: <1158174574.5328.37.camel@localhost> (raw)


Now that the problem with the rcu radix tree replace slot function has
been fixed, we can, if Christoph agrees:

Revert migrate_page_move_mapping() to use direct radix tree
slot replacement.  Fix up variable types to match modified
interfaces to radix_tree_{deref|replace}_slot().


Signed-off-by:  Lee Schermerhorn <lee.schermerhorn@hp.com>

 mm/migrate.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

Index: linux-2.6.18-rc6-mm2/mm/migrate.c
===================================================================
--- linux-2.6.18-rc6-mm2.orig/mm/migrate.c	2006-09-13 11:39:14.000000000 -0400
+++ linux-2.6.18-rc6-mm2/mm/migrate.c	2006-09-13 11:42:36.000000000 -0400
@@ -294,8 +294,7 @@ out:
 static int migrate_page_move_mapping(struct address_space *mapping,
 		struct page *newpage, struct page *page)
 {
-	struct page *current_page;
-	long index;
+	void **pslot;
 
 	if (!mapping) {
 		/* Anonymous page */
@@ -306,14 +305,11 @@ static int migrate_page_move_mapping(str
 
 	write_lock_irq(&mapping->tree_lock);
 
-	index = page_index(page);
-
-	current_page = (struct page *)radix_tree_lookup(
-						&mapping->page_tree,
-						index);
+	pslot = radix_tree_lookup_slot(&mapping->page_tree,
+ 					page_index(page));
 
 	if (page_count(page) != 2 + !!PagePrivate(page) ||
-			current_page != page) {
+			(struct page *)radix_tree_deref_slot(pslot) != page) {
 		write_unlock_irq(&mapping->tree_lock);
 		return -EAGAIN;
 	}
@@ -321,7 +317,7 @@ static int migrate_page_move_mapping(str
 	/*
 	 * Now we know that no one else is looking at the page.
 	 */
-	get_page(newpage);
+	get_page(newpage);	/* add cache reference */
 #ifdef CONFIG_SWAP
 	if (PageSwapCache(page)) {
 		SetPageSwapCache(newpage);
@@ -329,9 +325,14 @@ static int migrate_page_move_mapping(str
 	}
 #endif
 
-	radix_tree_delete(&mapping->page_tree, index);
-	radix_tree_insert(&mapping->page_tree, index, newpage);
+	radix_tree_replace_slot(pslot, newpage);
+
+	/*
+	 * Drop cache reference from old page.
+	 * We know this isn't the last reference.
+	 */
 	__put_page(page);
+
 	write_unlock_irq(&mapping->tree_lock);
 
 	return 0;


--
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-09-13 19:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-13 19:09 Lee Schermerhorn [this message]
2006-09-13 19:09 ` [PATCH 2.6.18-rc6.mm2] revert migrate_move_mapping to use direct radix tree slot update Lee Schermerhorn
2006-09-13 20:48 ` Christoph Lameter
2006-09-13 20:48   ` Christoph Lameter
2006-09-13 21:40   ` Lee Schermerhorn
2006-09-13 21:40     ` Lee Schermerhorn
2006-09-13 21:43     ` Christoph Lameter
2006-09-13 21:43       ` 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=1158174574.5328.37.camel@localhost \
    --to=lee.schermerhorn@hp.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --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 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.