Commit bc1cfde1 authored by Sidhartha Kumar's avatar Sidhartha Kumar Committed by Andrew Morton

mm/memory-failure: convert try_memory_failure_hugetlb() to folios

Use a struct folio rather than a head page in try_memory_failure_hugetlb. 
This converts one user of SetHPageMigratable to the folio equivalent.

Link: https://lkml.kernel.org/r/20230112204608.80136-3-sidhartha.kumar@oracle.comSigned-off-by: default avatarSidhartha Kumar <sidhartha.kumar@oracle.com>
Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 4c110ec9
...@@ -1860,7 +1860,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb ...@@ -1860,7 +1860,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
{ {
int res; int res;
struct page *p = pfn_to_page(pfn); struct page *p = pfn_to_page(pfn);
struct page *head; struct folio *folio;
unsigned long page_flags; unsigned long page_flags;
bool migratable_cleared = false; bool migratable_cleared = false;
...@@ -1873,8 +1873,8 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb ...@@ -1873,8 +1873,8 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
} else if (res == -EHWPOISON) { } else if (res == -EHWPOISON) {
pr_err("%#lx: already hardware poisoned\n", pfn); pr_err("%#lx: already hardware poisoned\n", pfn);
if (flags & MF_ACTION_REQUIRED) { if (flags & MF_ACTION_REQUIRED) {
head = compound_head(p); folio = page_folio(p);
res = kill_accessing_process(current, page_to_pfn(head), flags); res = kill_accessing_process(current, folio_pfn(folio), flags);
} }
return res; return res;
} else if (res == -EBUSY) { } else if (res == -EBUSY) {
...@@ -1885,16 +1885,16 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb ...@@ -1885,16 +1885,16 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
return action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED); return action_result(pfn, MF_MSG_UNKNOWN, MF_IGNORED);
} }
head = compound_head(p); folio = page_folio(p);
lock_page(head); folio_lock(folio);
if (hwpoison_filter(p)) { if (hwpoison_filter(p)) {
hugetlb_clear_page_hwpoison(head); hugetlb_clear_page_hwpoison(&folio->page);
if (migratable_cleared) if (migratable_cleared)
SetHPageMigratable(head); folio_set_hugetlb_migratable(folio);
unlock_page(head); folio_unlock(folio);
if (res == 1) if (res == 1)
put_page(head); folio_put(folio);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -1903,7 +1903,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb ...@@ -1903,7 +1903,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
* or demotion can be prevented by PageHWPoison flag. * or demotion can be prevented by PageHWPoison flag.
*/ */
if (res == 0) { if (res == 0) {
unlock_page(head); folio_unlock(folio);
if (__page_handle_poison(p) >= 0) { if (__page_handle_poison(p) >= 0) {
page_ref_inc(p); page_ref_inc(p);
res = MF_RECOVERED; res = MF_RECOVERED;
...@@ -1913,10 +1913,10 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb ...@@ -1913,10 +1913,10 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
return action_result(pfn, MF_MSG_FREE_HUGE, res); return action_result(pfn, MF_MSG_FREE_HUGE, res);
} }
page_flags = head->flags; page_flags = folio->flags;
if (!hwpoison_user_mappings(p, pfn, flags, head)) { if (!hwpoison_user_mappings(p, pfn, flags, &folio->page)) {
unlock_page(head); folio_unlock(folio);
return action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED); return action_result(pfn, MF_MSG_UNMAP_FAILED, MF_IGNORED);
} }
......
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