mm: fix hugepage migration

2.6.37 added an unmap_and_move_huge_page() for memory failure recovery,
but its anon_vma handling was still based around the 2.6.35 conventions.
Update it to use page_lock_anon_vma, get_anon_vma, page_unlock_anon_vma,
drop_anon_vma in the same way as we're now changing unmap_and_move().

I don't particularly like to propose this for stable when I've not seen
its problems in practice nor tested the solution: but it's clearly out of
synch at present.

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Rik van Riel <riel@redhat.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: "Jun'ichi Nomura" <j-nomura@ce.jp.nec.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: <stable@kernel.org> [2.6.37, 2.6.36]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Hugh Dickins and committed by
Linus Torvalds
fd4a4663 1ce82b69

+6 -17
+6 -17
mm/migrate.c
··· 827 827 int rc = 0; 828 828 int *result = NULL; 829 829 struct page *new_hpage = get_new_page(hpage, private, &result); 830 - int rcu_locked = 0; 831 830 struct anon_vma *anon_vma = NULL; 832 831 833 832 if (!new_hpage) ··· 841 842 } 842 843 843 844 if (PageAnon(hpage)) { 844 - rcu_read_lock(); 845 - rcu_locked = 1; 846 - 847 - if (page_mapped(hpage)) { 848 - anon_vma = page_anon_vma(hpage); 849 - atomic_inc(&anon_vma->external_refcount); 845 + anon_vma = page_lock_anon_vma(hpage); 846 + if (anon_vma) { 847 + get_anon_vma(anon_vma); 848 + page_unlock_anon_vma(anon_vma); 850 849 } 851 850 } 852 851 ··· 856 859 if (rc) 857 860 remove_migration_ptes(hpage, hpage); 858 861 859 - if (anon_vma && atomic_dec_and_lock(&anon_vma->external_refcount, 860 - &anon_vma->lock)) { 861 - int empty = list_empty(&anon_vma->head); 862 - spin_unlock(&anon_vma->lock); 863 - if (empty) 864 - anon_vma_free(anon_vma); 865 - } 866 - 867 - if (rcu_locked) 868 - rcu_read_unlock(); 862 + if (anon_vma) 863 + drop_anon_vma(anon_vma); 869 864 out: 870 865 unlock_page(hpage); 871 866