From: Andrew Morton Cc: Christoph Lameter Cc: Nick Piggin Cc: Shaohua Li Signed-off-by: Andrew Morton --- mm/migrate.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff -puN mm/migrate.c~page-migraton-handle-orphaned-pages-fix mm/migrate.c --- a/mm/migrate.c~page-migraton-handle-orphaned-pages-fix +++ a/mm/migrate.c @@ -642,20 +642,28 @@ static int unmap_and_move(new_page_t get } /* - * There are corner cases handling. - * 1. When a new swap-cache is read into, it is linked to LRU - * and treated as swapcache but has no rmap yet. - * Calling try_to_unmap() against a page->mapping==NULL page is - * BUG. So handle it here. - * 2. Orphaned page (see truncate_complete_page) might have - * fs-private metadata, the page is truncated. The page can be picked - * up due to memory offlineing. Everywhere else except page reclaim, - * the page is invisible to the vm, so the page can't be migrated. Try - * to free metadata, so the page can be freed. + * 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)) - try_to_release_page(page, GFP_KERNEL); + if (!PageAnon(page) && PagePrivate(page)) { + /* + * Go direct to try_to_free_buffers() here because + * a) that's what try_to_release_page() would do anyway + * b) we may be under rcu_read_lock() here, so we can't + * use GFP_KERNEL which is what try_to_release_page() + * needs to be effective. + */ + try_to_free_buffers(page); + } goto rcu_unlock; } _