aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
authorYe Liu <liuye@kylinos.cn>2026-05-15 10:01:43 +0800
committerAndrew Morton <akpm@linux-foundation.org>2026-05-28 21:31:10 -0700
commitecc5885b861050f4a969c5e3410a46a9349c44ed (patch)
tree88550a795defb457ca25361cfa7f50dce4fd5333 /mm
parentab3f1ed8d9c38e90f8a1e7a79f85cd0d00d6d02b (diff)
downloadlinux-next-history-ecc5885b861050f4a969c5e3410a46a9349c44ed.tar.gz
mm/memory-failure: remove hugetlb output parameter from try_memory_failure_hugetlb()
Use -ENOENT return value to distinguish "not a hugetlb page" from "hugetlb handled", instead of carrying an extra output parameter. Link: https://lore.kernel.org/20260515020144.164941-1-ye.liu@linux.dev Signed-off-by: Ye Liu <liuye@kylinos.cn> Suggested-by: Oscar Salvador <osalvador@suse.de> Acked-by: Miaohe Lin <linmiaohe@huawei.com> Acked-by: Oscar Salvador (SUSE) <osalvador@kernel.org> Cc: Naoya Horiguchi <nao.horiguchi@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory-failure.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index eff405a21c68b..1b8d0bade04a7 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2027,13 +2027,14 @@ out_unlock:
* So some of prechecks for hwpoison (pinning, and testing/setting
* PageHWPoison) should be done in single hugetlb_lock range.
* Returns:
- * 0 - not hugetlb, or recovered
+ * 0 - recovered
+ * -ENOENT - no hugetlb page
* -EBUSY - not recovered
* -EOPNOTSUPP - hwpoison_filter'ed
* -EHWPOISON - folio or exact page already poisoned
* -EFAULT - kill_accessing_process finds current->mm null
*/
-static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb)
+static int try_memory_failure_hugetlb(unsigned long pfn, int flags)
{
int res, rv;
struct page *p = pfn_to_page(pfn);
@@ -2041,13 +2042,11 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
unsigned long page_flags;
bool migratable_cleared = false;
- *hugetlb = 1;
retry:
res = get_huge_page_for_hwpoison(pfn, flags, &migratable_cleared);
switch (res) {
case MF_HUGETLB_NON_HUGEPAGE: /* fallback to normal page handling */
- *hugetlb = 0;
- return 0;
+ return -ENOENT;
case MF_HUGETLB_RETRY:
if (!(flags & MF_NO_RETRY)) {
flags |= MF_NO_RETRY;
@@ -2108,9 +2107,9 @@ retry:
}
#else
-static inline int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb)
+static inline int try_memory_failure_hugetlb(unsigned long pfn, int flags)
{
- return 0;
+ return -ENOENT;
}
static inline unsigned long folio_free_raw_hwp(struct folio *folio, bool flag)
@@ -2348,7 +2347,6 @@ int memory_failure(unsigned long pfn, int flags)
int res = 0;
unsigned long page_flags;
bool retry = true;
- int hugetlb = 0;
if (!sysctl_memory_failure_recovery)
panic("Memory failure on page %lx", pfn);
@@ -2387,8 +2385,11 @@ int memory_failure(unsigned long pfn, int flags)
}
try_again:
- res = try_memory_failure_hugetlb(pfn, flags, &hugetlb);
- if (hugetlb)
+ res = try_memory_failure_hugetlb(pfn, flags);
+ /*
+ * -ENOENT means the page we found is not hugetlb, so proceed with normal page handling
+ */
+ if (res != -ENOENT)
goto unlock_mutex;
if (TestSetPageHWPoison(p)) {