mm: remove a call to compound_head() from is_page_hwpoison()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 21 Mar 2024 14:24:44 +0000 (14:24 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 26 Apr 2024 03:56:00 +0000 (20:56 -0700)
We can call it only once instead of twice.

Link: https://lkml.kernel.org/r/20240321142448.1645400-7-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/page-flags.h

index 6fb3cd42ee596a5cb27893c7ae25a21c2b1b1553..94eb8a11a321289c949ecfed9e75fc0c0ab76216 100644 (file)
@@ -1065,11 +1065,14 @@ static inline bool PageHuge(const struct page *page)
  * best effort only and inherently racy: there is no way to synchronize with
  * failing hardware.
  */
-static inline bool is_page_hwpoison(struct page *page)
+static inline bool is_page_hwpoison(const struct page *page)
 {
+       const struct folio *folio;
+
        if (PageHWPoison(page))
                return true;
-       return PageHuge(page) && PageHWPoison(compound_head(page));
+       folio = page_folio(page);
+       return folio_test_hugetlb(folio) && PageHWPoison(&folio->page);
 }
 
 extern bool is_free_buddy_page(struct page *page);