Commit 04bac040 authored by Sidhartha Kumar's avatar Sidhartha Kumar Committed by Andrew Morton

mm/hugetlb: convert get_hwpoison_huge_page() to folios

Straightforward conversion of get_hwpoison_huge_page() to
get_hwpoison_hugetlb_folio().  Reduces two references to a head page in
memory-failure.c

[arnd@arndb.de: fix get_hwpoison_hugetlb_folio() stub]
  Link: https://lkml.kernel.org/r/20230119111920.635260-1-arnd@kernel.org
Link: https://lkml.kernel.org/r/20230118174039.14247-1-sidhartha.kumar@oracle.comSigned-off-by: default avatarSidhartha Kumar <sidhartha.kumar@oracle.com>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent b46402fa
...@@ -172,7 +172,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to, ...@@ -172,7 +172,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to,
long hugetlb_unreserve_pages(struct inode *inode, long start, long end, long hugetlb_unreserve_pages(struct inode *inode, long start, long end,
long freed); long freed);
int isolate_hugetlb(struct page *page, struct list_head *list); int isolate_hugetlb(struct page *page, struct list_head *list);
int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison); int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison);
int get_huge_page_for_hwpoison(unsigned long pfn, int flags, int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
bool *migratable_cleared); bool *migratable_cleared);
void putback_active_hugepage(struct page *page); void putback_active_hugepage(struct page *page);
...@@ -418,7 +418,7 @@ static inline int isolate_hugetlb(struct page *page, struct list_head *list) ...@@ -418,7 +418,7 @@ static inline int isolate_hugetlb(struct page *page, struct list_head *list)
return -EBUSY; return -EBUSY;
} }
static inline int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison) static inline int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison)
{ {
return 0; return 0;
} }
......
...@@ -7268,18 +7268,18 @@ int isolate_hugetlb(struct page *page, struct list_head *list) ...@@ -7268,18 +7268,18 @@ int isolate_hugetlb(struct page *page, struct list_head *list)
return ret; return ret;
} }
int get_hwpoison_huge_page(struct page *page, bool *hugetlb, bool unpoison) int get_hwpoison_hugetlb_folio(struct folio *folio, bool *hugetlb, bool unpoison)
{ {
int ret = 0; int ret = 0;
*hugetlb = false; *hugetlb = false;
spin_lock_irq(&hugetlb_lock); spin_lock_irq(&hugetlb_lock);
if (PageHeadHuge(page)) { if (folio_test_hugetlb(folio)) {
*hugetlb = true; *hugetlb = true;
if (HPageFreed(page)) if (folio_test_hugetlb_freed(folio))
ret = 0; ret = 0;
else if (HPageMigratable(page) || unpoison) else if (folio_test_hugetlb_migratable(folio) || unpoison)
ret = get_page_unless_zero(page); ret = folio_try_get(folio);
else else
ret = -EBUSY; ret = -EBUSY;
} }
......
...@@ -1257,28 +1257,28 @@ static inline bool HWPoisonHandlable(struct page *page, unsigned long flags) ...@@ -1257,28 +1257,28 @@ static inline bool HWPoisonHandlable(struct page *page, unsigned long flags)
static int __get_hwpoison_page(struct page *page, unsigned long flags) static int __get_hwpoison_page(struct page *page, unsigned long flags)
{ {
struct page *head = compound_head(page); struct folio *folio = page_folio(page);
int ret = 0; int ret = 0;
bool hugetlb = false; bool hugetlb = false;
ret = get_hwpoison_huge_page(head, &hugetlb, false); ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, false);
if (hugetlb) if (hugetlb)
return ret; return ret;
/* /*
* This check prevents from calling get_page_unless_zero() for any * This check prevents from calling folio_try_get() for any
* unsupported type of page in order to reduce the risk of unexpected * unsupported type of folio in order to reduce the risk of unexpected
* races caused by taking a page refcount. * races caused by taking a folio refcount.
*/ */
if (!HWPoisonHandlable(head, flags)) if (!HWPoisonHandlable(&folio->page, flags))
return -EBUSY; return -EBUSY;
if (get_page_unless_zero(head)) { if (folio_try_get(folio)) {
if (head == compound_head(page)) if (folio == page_folio(page))
return 1; return 1;
pr_info("%#lx cannot catch tail\n", page_to_pfn(page)); pr_info("%#lx cannot catch tail\n", page_to_pfn(page));
put_page(head); folio_put(folio);
} }
return 0; return 0;
...@@ -1347,11 +1347,11 @@ static int get_any_page(struct page *p, unsigned long flags) ...@@ -1347,11 +1347,11 @@ static int get_any_page(struct page *p, unsigned long flags)
static int __get_unpoison_page(struct page *page) static int __get_unpoison_page(struct page *page)
{ {
struct page *head = compound_head(page); struct folio *folio = page_folio(page);
int ret = 0; int ret = 0;
bool hugetlb = false; bool hugetlb = false;
ret = get_hwpoison_huge_page(head, &hugetlb, true); ret = get_hwpoison_hugetlb_folio(folio, &hugetlb, true);
if (hugetlb) if (hugetlb)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment