From 9c42fe4e30a9b934b1de66c2edca196563221392 Mon Sep 17 00:00:00 2001 From: Baolin Wang Date: Thu, 28 Apr 2022 23:16:09 -0700 Subject: mm: migrate: simplify the refcount validation when migrating hugetlb mapping There is no need to validate the hugetlb page's refcount before trying to freeze the hugetlb page's expected refcount, instead we can just rely on the page_ref_freeze() to simplify the validation. Moreover we are always under the page lock when migrating the hugetlb page mapping, which means nowhere else can remove it from the page cache, so we can remove the xas_load() validation under the i_pages lock. Link: https://lkml.kernel.org/r/eb2fbbeaef2b1714097b9dec457426d682ee0635.1649676424.git.baolin.wang@linux.alibaba.com Signed-off-by: Baolin Wang Acked-by: Mike Kravetz Cc: Matthew Wilcox Cc: "Huang, Ying" Cc: Muchun Song Cc: Alistair Popple Cc: Zi Yan Signed-off-by: Andrew Morton --- mm/migrate.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'mm/migrate.c') diff --git a/mm/migrate.c b/mm/migrate.c index 35f6416d2953..f97d724b8fc0 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -471,11 +471,6 @@ int migrate_huge_page_move_mapping(struct address_space *mapping, xas_lock_irq(&xas); expected_count = 2 + page_has_private(page); - if (page_count(page) != expected_count || xas_load(&xas) != page) { - xas_unlock_irq(&xas); - return -EAGAIN; - } - if (!page_ref_freeze(page, expected_count)) { xas_unlock_irq(&xas); return -EAGAIN; -- cgit v1.2.3