Skip to content

Commit

Permalink
mm: memory-failure: use local variable huge to check hugetlb page
Browse files Browse the repository at this point in the history
Use local variable huge to check whether page is hugetlb page to avoid
calling PageHuge() multiple times to save cpu cycles.  PageHuge() will be
stable while extra page refcnt is held.

Link: https://lkml.kernel.org/r/20230711055016.2286677-5-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Miaohe Lin authored and Andrew Morton committed Aug 18, 2023
1 parent 80ee7cb commit 55c7ac4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,7 @@ static int soft_offline_in_use_page(struct page *page)
}

lock_page(page);
if (!PageHuge(page))
if (!huge)
wait_on_page_writeback(page);
if (PageHWPoison(page)) {
unlock_page(page);
Expand All @@ -2626,7 +2626,7 @@ static int soft_offline_in_use_page(struct page *page)
return 0;
}

if (!PageHuge(page) && PageLRU(page) && !PageSwapCache(page))
if (!huge && PageLRU(page) && !PageSwapCache(page))
/*
* Try to invalidate first. This should work for
* non dirty unmapped page cache pages.
Expand Down

0 comments on commit 55c7ac4

Please sign in to comment.