Migrate-on-fault prototype 1/5 V0.1 - separate unmap from radix tree replace
Subsystems (5)
Migrate-on-fault prototype 1/5 V0.1 - separate unmap from radix tree replace
The migrate_page_remove_references() function performs two distinct
operations: actually attempting to remove pte references from the page via try_to_unmap() and replacing the page with a new page in the page's mapping's radix tree. This patch separates these operations into two functions so that they can be called separately.
Then, migrate_page_remove_references() is replaced with a function named migrate_page_unmap_and_replace() to indicate the two operations, and existing calls in mm/vmscan.c:migrate_page() and fs/buffer.c:buffer_migrate_page() are updated.
Note: this results in each of the functions having to load the mapping when called for direct migration. Perhaps passing mapping as an argument would be preferable?
Subsequent patches in the series will make use of the separate operations.
Eventually, we can remove migrate_page_unmap_and_replace()
Index: linux-2.6.16-rc5-git8/fs/buffer.c
===================================================================
--- linux-2.6.16-rc5-git8.orig/fs/buffer.c 2006-03-06 13:40:46.000000000 -0500
+++ linux-2.6.16-rc5-git8/fs/buffer.c 2006-03-08 10:46:33.000000000 -0500
@@ -3060,6 +3060,7 @@ int buffer_migrate_page(struct page *new {
struct address_space *mapping = page->mapping;
struct buffer_head *bh, *head;
+ static const int nr_refs = 3; /* cache + bufs + current */
if (!mapping)
return -EAGAIN;
@@ -3069,7 +3070,7 @@ int buffer_migrate_page(struct page *new
head = page_buffers(page);
- if (migrate_page_remove_references(newpage, page, 3))
+ if (migrate_page_unmap_and_replace(newpage, page, nr_refs)) return -EAGAIN;
bh = head;
@@ -3083,7 +3084,7 @@ int buffer_migrate_page(struct page *new ClearPagePrivate(page);set_page_private(newpage, page_private(page)); set_page_private(page, 0);
- put_page(page);
+ put_page(page); /* transfer buf ref to newpage */ get_page(newpage);
bh = head;
Index: linux-2.6.16-rc5-git8/mm/vmscan.c
===================================================================
--- linux-2.6.16-rc5-git8.orig/mm/vmscan.c 2006-03-06 13:40:48.000000000 -0500
+++ linux-2.6.16-rc5-git8/mm/vmscan.c 2006-03-08 10:44:39.000000000 -0500
@@ -685,14 +685,12 @@ EXPORT_SYMBOL(swap_page);
*/
/*
- * Remove references for a page and establish the new page with the correct
- * basic settings to be able to stop accesses to the page.
+ * try to remove pte references from page in preparation to migrate to
+ * a new page.
*/
-int migrate_page_remove_references(struct page *newpage,
- struct page *page, int nr_refs)
+int migrate_page_try_to_unmap(struct page *page, int nr_refs) {
struct address_space *mapping = page_mapping(page);
- struct page **radix_pointer;
/*
* Avoid doing any of the following work if the page count @@ -721,14 +719,27 @@ int migrate_page_remove_references(struc
* If the page was not migrated then the PageSwapCache bit
* is still set and the operation may continue.
*/
- try_to_unmap(page, 1);
+ try_to_unmap(page, 1); /* ignore_refs */
/*
- * Give up if we were unable to remove all mappings.
+ * Fail if we were unable to remove all mappings. */
if (page_mapcount(page))
return 1;
+ return 0;
+}
+EXPORT_SYMBOL(migrate_page_try_to_unmap);
+
+/*
+ * replace page in it's mapping's radix tree with newpage
+ */
+int migrate_page_replace_in_mapping(struct page *newpage,
+ struct page *page, int nr_refs)
+{
+ struct address_space *mapping = page_mapping(page);
+ struct page **radix_pointer;
+write_lock_irq(&mapping->tree_lock);
radix_pointer = (struct page **)radix_tree_lookup_slot( @@ -749,7 +760,7 @@ int migrate_page_remove_references(struc
* find it through the radix tree update before we are finished
* copying the page.
*/
- get_page(newpage);
+ get_page(newpage); /* add cache ref */ newpage->index = page->index;newpage->mapping = page->mapping;
if (PageSwapCache(page)) {
@@ -758,12 +769,30 @@ int migrate_page_remove_references(struc }
*radix_pointer = newpage;
- __put_page(page);
+ __put_page(page); /* drop cache ref */write_unlock_irq(&mapping->tree_lock);
return 0;
}
-EXPORT_SYMBOL(migrate_page_remove_references); +EXPORT_SYMBOL(migrate_page_replace_in_mapping);
+
+
+/*
+ * Remove references for a page and establish the new page with the correct
+ * basic settings to be able to stop accesses to the page.
+ */
+int migrate_page_unmap_and_replace(struct page *newpage,
+ struct page *page, int nr_refs)
+{
+ /*
+ * Give up if we were unable to remove all mappings.
+ */
+ if (migrate_page_try_to_unmap(page, nr_refs))
+ return 1;
+
+ return migrate_page_replace_in_mapping(page, newpage, nr_refs); +}
+EXPORT_SYMBOL(migrate_page_unmap_and_replace);
/*
* Copy the page to its new location
@@ -813,9 +842,11 @@ EXPORT_SYMBOL(migrate_page_copy);
*/
int migrate_page(struct page *newpage, struct page *page) {
+ static const int nr_refs = 2; /* cache + current */ +
BUG_ON(PageWriteback(page)); /* Writeback must be complete */
- if (migrate_page_remove_references(newpage, page, 2))
+ if (migrate_page_unmap_and_replace(newpage, page, nr_refs)) return -EAGAIN;
migrate_page_copy(newpage, page);
Index: linux-2.6.16-rc5-git8/include/linux/swap.h
===================================================================
--- linux-2.6.16-rc5-git8.orig/include/linux/swap.h 2006-03-06 13:40:47.000000000 -0500
+++ linux-2.6.16-rc5-git8/include/linux/swap.h 2006-03-08 10:44:14.000000000 -0500
@@ -193,7 +193,9 @@ extern int isolate_lru_page(struct page extern int putback_lru_pages(struct list_head *l);
extern int migrate_page(struct page *, struct page *); extern void migrate_page_copy(struct page *, struct page *); -extern int migrate_page_remove_references(struct page *, struct page *, int);
+extern int migrate_page_try_to_unmap(struct page *, int); +extern int migrate_page_replace_in_mapping(struct page *, struct page *, int);
+extern int migrate_page_unmap_and_replace(struct page *, struct page *, int);
extern int migrate_pages(struct list_head *l, struct list_head *t, struct list_head *moved, struct list_head *failed);
extern int fail_migrate_page(struct page *, struct page *);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Review int buffer_migrate_page(struct page *new · line 3088
Quoted 7 lines · Lee Schermerhorn
(quoted diff) +1
-1@@ -3083,7 +3084,7 @@ int buffer_migrate_page(struct page *new ClearPagePrivate(page); set_page_private(newpage, page_private(page)); set_page_private(page, 0); - put_page(page); + put_page(page); /* transfer buf ref to newpage */ get_page(newpage);
Is it just me, or do these have some serious whitespace borkage?
Do you have a clean version of them posted anywhere?
-- Dave
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 10 lines · Dave Hansen
Review int buffer_migrate_page(struct page *new · line 3088
Quoted 7 lines · Lee Schermerhorn
(quoted diff) +1
-1@@ -3083,7 +3084,7 @@ int buffer_migrate_page(struct page *new ClearPagePrivate(page); set_page_private(newpage, page_private(page)); set_page_private(page, 0); - put_page(page); + put_page(page); /* transfer buf ref to newpage */ get_page(newpage);Is it just me, or do these have some serious whitespace borkage?
<heavy sigh> Probably. I was fighting with the mailer. Took several attempts to import the text files. Even sent one to myself first, before sending it out. Looked OK.
Quoted 2 lines
Do you have a clean version of them posted anywhere?
I just placed a tarball at:
http://free.linux.hp.com/~lts/Patches/PageMigration/
I took a look at the files in the tar ball. Several of them do seem to have lines consisting of a single space for what were empty context lines in the patches. The patches were generated via quilt which usually complains about trailing white space and I always fix them.
Some of the lines in the discussion above the patches do seem to have trailing spaces, but that's probably just my fat fingers...
Lee
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 2 lines · Lee Schermerhorn
Migrate-on-fault prototype 1/5 V0.1 - separate unmap from radix tree replace
Previous send mangled by mailer. Try this:
Migrate-on-fault prototype 1/5 V0.1 - separate unmap from radix tree replace
The migrate_page_remove_references() function performs two distinct
operations: actually attempting to remove pte references from the page via try_to_unmap() and replacing the page with a new page in the page's mapping's radix tree. This patch separates these operations into two functions so that they can be called separately.
Then, migrate_page_remove_references() is replaced with a function named migrate_page_unmap_and_replace() to indicate the two operations, and existing calls in mm/vmscan.c:migrate_page() and fs/buffer.c:buffer_migrate_page() are updated.
Note: this results in each of the functions having to load the mapping when called for direct migration. Perhaps passing mapping as an argument would be preferable?
Subsequent patches in the series will make use of the separate operations.
Eventually, we can remove migrate_page_unmap_and_replace()
fs/buffer.c +3 -2
@@ -3060,6 +3060,7 @@ int buffer_migrate_page(struct page *new {struct address_space *mapping = page->mapping;struct buffer_head *bh, *head; +static const int nr_refs =3 ;/* cache + bufs + current */ if (!mapping)return -EAGAIN ;
@@ -3069,7 +3070,7 @@ int buffer_migrate_page(struct page *new head =page_buffers (page); -if (migrate_page_remove_references (newpage, page,3 )) +if (migrate_page_unmap_and_replace (newpage, page, nr_refs))return -EAGAIN ; bh = head;
@@ -3083,7 +3084,7 @@ int buffer_migrate_page(struct page *newClearPagePrivate (page);set_page_private (newpage,page_private (page));set_page_private (page,0 ); -put_page (page); +put_page (page);/* transfer buf ref to newpage */ get_page (newpage); bh = head;
mm/vmscan.c +42 -11
98 lines not on this page · raw message
include/linux/swap.h +3 -1
@@ -193,7 +193,9 @@ extern int isolate_lru_page(struct pageextern int putback_lru_pages (struct list_head *l);extern int migrate_page (struct page *,struct page *);extern void migrate_page_copy (struct page *,struct page *); -extern int migrate_page_remove_references (struct page *,struct page *,int ); +extern int migrate_page_try_to_unmap (struct page *,int ); +extern int migrate_page_replace_in_mapping (struct page *,struct page *,int ); +extern int migrate_page_unmap_and_replace (struct page *,struct page *,int );extern int migrate_pages (struct list_head *l,struct list_head *t,struct list_head *moved,struct list_head *failed);extern int fail_migrate_page (struct page *,struct page *);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>