2023-07-08 09:13:53

by Miaohe Lin

[permalink] [raw]
Subject: [PATCH 4/8] mm: memory-failure: use local variable huge to check hugetlb page

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.

Signed-off-by: Miaohe Lin <[email protected]>
---
mm/memory-failure.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 905758af70f3..88e48a4801ee 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2621,7 +2621,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);
@@ -2630,7 +2630,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.
--
2.33.0



2023-07-10 08:35:28

by Naoya Horiguchi

[permalink] [raw]
Subject: Re: [PATCH 4/8] mm: memory-failure: use local variable huge to check hugetlb page

On Sat, Jul 08, 2023 at 04:57:40PM +0800, Miaohe Lin wrote:
> 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.
>
> Signed-off-by: Miaohe Lin <[email protected]>

Acked-by: Naoya Horiguchi <[email protected]>