diff mbox series

[3/5] memory-failure: Use hugetlb_pfn_folio

Message ID 20240301214712.2853147-4-willy@infradead.org (mailing list archive)
State New
Headers show
Series Remove some races around folio_test_hugetlb | expand

Commit Message

Matthew Wilcox March 1, 2024, 9:47 p.m. UTC
Calling folio_test_hugetlb() is inefficient; hugetlb_pfn_folio()
does less work.  This is a safe use of hugetlb_pfn_folio() as
__get_huge_page_for_hwpoison() holds the hugetlb_lock.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 mm/memory-failure.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 9349948f1abf..e42d0cd7888d 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1987,12 +1987,12 @@  void folio_clear_hugetlb_hwpoison(struct folio *folio)
 int __get_huge_page_for_hwpoison(unsigned long pfn, int flags,
 				 bool *migratable_cleared)
 {
-	struct page *page = pfn_to_page(pfn);
-	struct folio *folio = page_folio(page);
+	struct folio *folio;
 	int ret = 2;	/* fallback to normal page handling */
 	bool count_increased = false;
 
-	if (!folio_test_hugetlb(folio))
+	folio = hwpoison_pfn_folio(pfn);
+	if (!folio)
 		goto out;
 
 	if (flags & MF_COUNT_INCREASED) {