Commit 62e1c553 authored by Shaohua Li's avatar Shaohua Li Committed by Linus Torvalds

page migraton: handle orphaned pages

Orphaned page might have fs-private metadata, the page is truncated.  As
the page hasn't mapping, page migration refuse to migrate the page.  It
appears the page is only freed in page reclaim and if zone watermark is
low, the page is never freed, as a result migration always fail.  I thought
we could free the metadata so such page can be freed in migration and make
migration more reliable.

[akpm@linux-foundation.org: go direct to try_to_free_buffers()]
Signed-off-by: default avatarShaohua Li <shaohua.li@intel.com>
Acked-by: default avatarNick Piggin <npiggin@suse.de>
Acked-by: default avatarChristoph Lameter <clameter@sgi.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7786fa9a
...@@ -640,15 +640,33 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private, ...@@ -640,15 +640,33 @@ static int unmap_and_move(new_page_t get_new_page, unsigned long private,
rcu_read_lock(); rcu_read_lock();
rcu_locked = 1; rcu_locked = 1;
} }
/*
* Corner case handling:
* 1. When a new swap-cache page is read into, it is added to the LRU
* and treated as swapcache but it has no rmap yet.
* Calling try_to_unmap() against a page->mapping==NULL page will
* trigger a BUG. So handle it here.
* 2. An orphaned page (see truncate_complete_page) might have
* fs-private metadata. The page can be picked up due to memory
* offlining. Everywhere else except page reclaim, the page is
* invisible to the vm, so the page can not be migrated. So try to
* free the metadata, so the page can be freed.
*/
if (!page->mapping) {
if (!PageAnon(page) && PagePrivate(page)) {
/* /*
* This is a corner case handling. * Go direct to try_to_free_buffers() here because
* When a new swap-cache is read into, it is linked to LRU * a) that's what try_to_release_page() would do anyway
* and treated as swapcache but has no rmap yet. * b) we may be under rcu_read_lock() here, so we can't
* Calling try_to_unmap() against a page->mapping==NULL page is * use GFP_KERNEL which is what try_to_release_page()
* BUG. So handle it here. * needs to be effective.
*/ */
if (!page->mapping) try_to_free_buffers(page);
}
goto rcu_unlock; goto rcu_unlock;
}
/* Establish migration ptes or remove ptes */ /* Establish migration ptes or remove ptes */
try_to_unmap(page, 1); try_to_unmap(page, 1);
......
...@@ -84,7 +84,7 @@ EXPORT_SYMBOL(cancel_dirty_page); ...@@ -84,7 +84,7 @@ EXPORT_SYMBOL(cancel_dirty_page);
/* /*
* If truncate cannot remove the fs-private metadata from the page, the page * If truncate cannot remove the fs-private metadata from the page, the page
* becomes anonymous. It will be left on the LRU and may even be mapped into * becomes orphaned. It will be left on the LRU and may even be mapped into
* user pagetables if we're racing with filemap_fault(). * user pagetables if we're racing with filemap_fault().
* *
* We need to bale out if page->mapping is no longer equal to the original * We need to bale out if page->mapping is no longer equal to the original
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment