summaryrefslogtreecommitdiffstats
path: root/mm/memory-failure.c
diff options
context:
space:
mode:
authorNaoya Horiguchi <naoya.horiguchi@nec.com>2022-04-29 08:16:02 +0200
committerakpm <akpm@linux-foundation.org>2022-04-29 08:16:02 +0200
commitb283d983a7a6ffe3939ff26f06d151331a7c1071 (patch)
tree369be38981efe0927f6612c66704828fe3f95e41 /mm/memory-failure.c
parentmm/memory-failure.c: dissolve truncated hugetlb page (diff)
downloadlinux-b283d983a7a6ffe3939ff26f06d151331a7c1071.tar.xz
linux-b283d983a7a6ffe3939ff26f06d151331a7c1071.zip
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.jp Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com> Suggested-by: Mike Kravetz <mike.kravetz@oracle.com> Suggested-by: Miaohe Lin <linmiaohe@huawei.com> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/memory-failure.c')
-rw-r--r--mm/memory-failure.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index e01a2da803e2..9711c0eb70b0 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1517,7 +1517,9 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags)
if (flags & MF_COUNT_INCREASED) {
ret = 1;
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);
if (ret)
count_increased = true;