Commit b283d983 authored by Naoya Horiguchi's avatar Naoya Horiguchi Committed by akpm

mm, hugetlb, hwpoison: separate branch for free and in-use hugepage

We know that HPageFreed pages should have page refcount 0, so
get_page_unless_zero() always fails and returns 0.  So explicitly separate
the branch based on page state for minor optimization and better
readability.

Link: https://lkml.kernel.org/r/20220415041848.GA3034499@ik1-406-35019.vs.sakura.ne.jpSigned-off-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
Suggested-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
Suggested-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent ef526b17
...@@ -6776,7 +6776,9 @@ int get_hwpoison_huge_page(struct page *page, bool *hugetlb) ...@@ -6776,7 +6776,9 @@ int get_hwpoison_huge_page(struct page *page, bool *hugetlb)
spin_lock_irq(&hugetlb_lock); spin_lock_irq(&hugetlb_lock);
if (PageHeadHuge(page)) { if (PageHeadHuge(page)) {
*hugetlb = true; *hugetlb = true;
if (HPageFreed(page) || HPageMigratable(page)) if (HPageFreed(page))
ret = 0;
else if (HPageMigratable(page))
ret = get_page_unless_zero(page); ret = get_page_unless_zero(page);
else else
ret = -EBUSY; ret = -EBUSY;
......
...@@ -1517,7 +1517,9 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags) ...@@ -1517,7 +1517,9 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags)
if (flags & MF_COUNT_INCREASED) { if (flags & MF_COUNT_INCREASED) {
ret = 1; ret = 1;
count_increased = true; count_increased = true;
} else if (HPageFreed(head) || HPageMigratable(head)) { } else if (HPageFreed(head)) {
ret = 0;
} else if (HPageMigratable(head)) {
ret = get_page_unless_zero(head); ret = get_page_unless_zero(head);
if (ret) if (ret)
count_increased = true; count_increased = true;
......
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