Skip to content

Commit fd4a466

Browse files
Hugh Dickinstorvalds
authored andcommitted
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>
1 parent 1ce82b6 commit fd4a466

1 file changed

Lines changed: 6 additions & 17 deletions

File tree

‎mm/migrate.c‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,6 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
827827
int rc = 0;
828828
int *result = NULL;
829829
struct page *new_hpage = get_new_page(hpage, private, &result);
830-
int rcu_locked = 0;
831830
struct anon_vma *anon_vma = NULL;
832831

833832
if (!new_hpage)
@@ -842,12 +841,10 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
842841
}
843842

844843
if (PageAnon(hpage)) {
845-
rcu_read_lock();
846-
rcu_locked = 1;
847-
848-
if (page_mapped(hpage)) {
849-
anon_vma = page_anon_vma(hpage);
850-
atomic_inc(&anon_vma->external_refcount);
844+
anon_vma = page_lock_anon_vma(hpage);
845+
if (anon_vma) {
846+
get_anon_vma(anon_vma);
847+
page_unlock_anon_vma(anon_vma);
851848
}
852849
}
853850

@@ -859,16 +856,8 @@ static int unmap_and_move_huge_page(new_page_t get_new_page,
859856
if (rc)
860857
remove_migration_ptes(hpage, hpage);
861858

862-
if (anon_vma && atomic_dec_and_lock(&anon_vma->external_refcount,
863-
&anon_vma->lock)) {
864-
int empty = list_empty(&anon_vma->head);
865-
spin_unlock(&anon_vma->lock);
866-
if (empty)
867-
anon_vma_free(anon_vma);
868-
}
869-
870-
if (rcu_locked)
871-
rcu_read_unlock();
859+
if (anon_vma)
860+
drop_anon_vma(anon_vma);
872861
out:
873862
unlock_page(hpage);
874863

0 commit comments

Comments
 (0)