* [PATCH v2] mm/memory-failure: remove hugetlb output parameter from try_memory_failure_hugetlb()
@ 2026-05-15 2:01 Ye Liu
2026-05-15 3:11 ` Miaohe Lin
2026-05-15 5:48 ` Oscar Salvador (SUSE)
0 siblings, 2 replies; 3+ messages in thread
From: Ye Liu @ 2026-05-15 2:01 UTC (permalink / raw)
To: Miaohe Lin, Andrew Morton
Cc: Ye Liu, Oscar Salvador, Naoya Horiguchi, linux-mm, linux-kernel
From: Ye Liu <liuye@kylinos.cn>
Use -ENOENT return value to distinguish "not a hugetlb page" from
"hugetlb handled", instead of carrying an extra output parameter.
Suggested-by: Oscar Salvador <osalvador@suse.de>
Signed-off-by: Ye Liu <liuye@kylinos.cn>
---
Changes in v2:
- Remove the 'hugetlb' output parameter from try_memory_failure_hugetlb()
as suggested by Oscar Salvador.
- Return -ENOENT for MF_HUGETLB_NON_HUGEPAGE case to let caller fall back
to normal page handling.
- Update memory_failure() to check res != -ENOENT instead of using a
separate boolean variable.
- Link: https://lore.kernel.org/all/20260513024853.65566-1-ye.liu@linux.dev/
mm/memory-failure.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 866c4428ac7e..e7cf952221df 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2026,13 +2026,14 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags,
* 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);
@@ -2040,13 +2041,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;
@@ -2107,9 +2106,9 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb
}
#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)
@@ -2347,7 +2346,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);
@@ -2386,8 +2384,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)) {
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mm/memory-failure: remove hugetlb output parameter from try_memory_failure_hugetlb()
2026-05-15 2:01 [PATCH v2] mm/memory-failure: remove hugetlb output parameter from try_memory_failure_hugetlb() Ye Liu
@ 2026-05-15 3:11 ` Miaohe Lin
2026-05-15 5:48 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 3+ messages in thread
From: Miaohe Lin @ 2026-05-15 3:11 UTC (permalink / raw)
To: Ye Liu
Cc: Ye Liu, Oscar Salvador, Naoya Horiguchi, linux-mm, linux-kernel,
Andrew Morton
On 2026/5/15 10:01, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> Use -ENOENT return value to distinguish "not a hugetlb page" from
> "hugetlb handled", instead of carrying an extra output parameter.
>
> Suggested-by: Oscar Salvador <osalvador@suse.de>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
Thanks for your cleanup.
Acked-by: Miaohe Lin <linmiaohe@huawei.com>
Thanks.
.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] mm/memory-failure: remove hugetlb output parameter from try_memory_failure_hugetlb()
2026-05-15 2:01 [PATCH v2] mm/memory-failure: remove hugetlb output parameter from try_memory_failure_hugetlb() Ye Liu
2026-05-15 3:11 ` Miaohe Lin
@ 2026-05-15 5:48 ` Oscar Salvador (SUSE)
1 sibling, 0 replies; 3+ messages in thread
From: Oscar Salvador (SUSE) @ 2026-05-15 5:48 UTC (permalink / raw)
To: Ye Liu
Cc: Miaohe Lin, Andrew Morton, Ye Liu, Oscar Salvador,
Naoya Horiguchi, linux-mm, linux-kernel
On Fri, May 15, 2026 at 10:01:43AM +0800, Ye Liu wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> Use -ENOENT return value to distinguish "not a hugetlb page" from
> "hugetlb handled", instead of carrying an extra output parameter.
>
> Suggested-by: Oscar Salvador <osalvador@suse.de>
> Signed-off-by: Ye Liu <liuye@kylinos.cn>
Acked-by: Oscar Salvador (SUSE) <osalvador@kernel.org>
--
Oscar Salvador
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-15 5:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-15 2:01 [PATCH v2] mm/memory-failure: remove hugetlb output parameter from try_memory_failure_hugetlb() Ye Liu
2026-05-15 3:11 ` Miaohe Lin
2026-05-15 5:48 ` Oscar Salvador (SUSE)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.