* [PATCH 1/1] x86/mm: fix spurious warning on __add_pages() failure
@ 2026-10-01 8:15 Lance Yang
2026-10-01 9:12 ` Muchun Song
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lance Yang @ 2026-10-01 8:15 UTC (permalink / raw)
To: dave.hansen
Cc: luto, peterz, tglx, mingo, bp, x86, hpa, linux-kernel, linux-mm,
david, muchun.song, Lance Yang
__add_pages() can fail if we run out of memory. The caller already
handles that, so we shouldn't WARN_ON_ONCE() just because an allocation
failed.
Let's return the error instead, and only update the end-of-memory
variables after __add_pages() succeeds.
Fixes: 10f22dde556d ("x86: arch/x86/mm/init_64.c printk fixes")
Reported-by: David Hildenbrand <david@kernel.org>
Link: https://lore.kernel.org/all/d4fac8af-fd71-47a2-bfe9-3c6559b92209@kernel.org/
Suggested-by: Muchun Song <muchun.song@linux.dev>
Link: https://lore.kernel.org/all/203892F4-B04A-4F69-A1B3-DC1619176C67@linux.dev/
Signed-off-by: Lance Yang <lance.yang@linux.dev>
---
arch/x86/mm/init_64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 70e682180291a..8b6d86fb5a42e 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -970,7 +970,8 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
return -ERANGE;
ret = __add_pages(nid, start_pfn, nr_pages, params);
- WARN_ON_ONCE(ret);
+ if (ret)
+ return ret;
/*
* Special case: add_pages() is called by memremap_pages() for adding device
--
2.49.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] x86/mm: fix spurious warning on __add_pages() failure
2026-10-01 8:15 [PATCH 1/1] x86/mm: fix spurious warning on __add_pages() failure Lance Yang
@ 2026-10-01 9:12 ` Muchun Song
2026-10-01 9:43 ` David Hildenbrand (Arm)
2026-10-01 12:08 ` [tip: x86/mm] x86/mm: Fix " tip-bot2 for Lance Yang
2 siblings, 0 replies; 4+ messages in thread
From: Muchun Song @ 2026-10-01 9:12 UTC (permalink / raw)
To: Lance Yang
Cc: dave.hansen, luto, peterz, tglx, mingo, bp, x86, hpa,
linux-kernel, linux-mm, david
> On Oct 1, 2026, at 16:15, Lance Yang <lance.yang@linux.dev> wrote:
>
> __add_pages() can fail if we run out of memory. The caller already
> handles that, so we shouldn't WARN_ON_ONCE() just because an allocation
> failed.
>
> Let's return the error instead, and only update the end-of-memory
> variables after __add_pages() succeeds.
>
> Fixes: 10f22dde556d ("x86: arch/x86/mm/init_64.c printk fixes")
> Reported-by: David Hildenbrand <david@kernel.org>
> Link: https://lore.kernel.org/all/d4fac8af-fd71-47a2-bfe9-3c6559b92209@kernel.org/
> Suggested-by: Muchun Song <muchun.song@linux.dev>
> Link: https://lore.kernel.org/all/203892F4-B04A-4F69-A1B3-DC1619176C67@linux.dev/
> Signed-off-by: Lance Yang <lance.yang@linux.dev>
I noticed that __add_pages() already reports invalid parameters where
appropriate, while errors such as -ENOMEM can legitimately occur and
are propagated to the caller. Therefore, the additional
WARN_ON_ONCE(ret) in add_pages() seems unnecessary to me.
The change looks reasonable.
Acked-by: Muchun Song <muchun.song@linux.dev>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] x86/mm: fix spurious warning on __add_pages() failure
2026-10-01 8:15 [PATCH 1/1] x86/mm: fix spurious warning on __add_pages() failure Lance Yang
2026-10-01 9:12 ` Muchun Song
@ 2026-10-01 9:43 ` David Hildenbrand (Arm)
2026-10-01 12:08 ` [tip: x86/mm] x86/mm: Fix " tip-bot2 for Lance Yang
2 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand (Arm) @ 2026-10-01 9:43 UTC (permalink / raw)
To: Lance Yang, dave.hansen
Cc: luto, peterz, tglx, mingo, bp, x86, hpa, linux-kernel, linux-mm,
muchun.song
On 10/1/26 10:15, Lance Yang wrote:
> __add_pages() can fail if we run out of memory. The caller already
> handles that, so we shouldn't WARN_ON_ONCE() just because an allocation
> failed.
>
> Let's return the error instead, and only update the end-of-memory
> variables after __add_pages() succeeds.
>
> Fixes: 10f22dde556d ("x86: arch/x86/mm/init_64.c printk fixes")
> Reported-by: David Hildenbrand <david@kernel.org>
> Link: https://lore.kernel.org/all/d4fac8af-fd71-47a2-bfe9-3c6559b92209@kernel.org/
> Suggested-by: Muchun Song <muchun.song@linux.dev>
> Link: https://lore.kernel.org/all/203892F4-B04A-4F69-A1B3-DC1619176C67@linux.dev/
> Signed-off-by: Lance Yang <lance.yang@linux.dev>
> ---
> arch/x86/mm/init_64.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 70e682180291a..8b6d86fb5a42e 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -970,7 +970,8 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
> return -ERANGE;
>
> ret = __add_pages(nid, start_pfn, nr_pages, params);
> - WARN_ON_ONCE(ret);
> + if (ret)
> + return ret;
>
> /*
> * Special case: add_pages() is called by memremap_pages() for adding device
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: x86/mm] x86/mm: Fix spurious warning on __add_pages() failure
2026-10-01 8:15 [PATCH 1/1] x86/mm: fix spurious warning on __add_pages() failure Lance Yang
2026-10-01 9:12 ` Muchun Song
2026-10-01 9:43 ` David Hildenbrand (Arm)
@ 2026-10-01 12:08 ` tip-bot2 for Lance Yang
2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Lance Yang @ 2026-10-01 12:08 UTC (permalink / raw)
To: linux-tip-commits
Cc: David Hildenbrand, Muchun Song, Lance Yang, Dave Hansen, x86,
linux-kernel
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: d92b5ac5aeba1ffc734576e30a5bca882722de76
Gitweb: https://git.kernel.org/tip/d92b5ac5aeba1ffc734576e30a5bca882722de76
Author: Lance Yang <lance.yang@linux.dev>
AuthorDate: Thu, 01 Oct 2026 16:15:55 +08:00
Committer: Dave Hansen <dave.hansen@linux.intel.com>
CommitterDate: Thu, 01 Oct 2026 05:04:44 -07:00
x86/mm: Fix spurious warning on __add_pages() failure
__add_pages() can fail if we run out of memory. Callers already handle
that. Do not WARN_ON_ONCE() just because an allocation failed.
Return the error instead, and only update the end-of-memory variables
after __add_pages() succeeds.
[ dhansen: imperative voice changelog fixups ]
Fixes: 10f22dde556d ("x86: arch/x86/mm/init_64.c printk fixes")
Reported-by: David Hildenbrand <david@kernel.org>
Suggested-by: Muchun Song <muchun.song@linux.dev>
Signed-off-by: Lance Yang <lance.yang@linux.dev>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Muchun Song <muchun.song@linux.dev>
Link: https://lore.kernel.org/all/d4fac8af-fd71-47a2-bfe9-3c6559b92209@kernel.org/
Link: https://lore.kernel.org/all/203892F4-B04A-4F69-A1B3-DC1619176C67@linux.dev/
Link: https://patch.msgid.link/20261001081555.35485-1-lance.yang@linux.dev
---
arch/x86/mm/init_64.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 70e6821..8b6d86f 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -970,7 +970,8 @@ int add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
return -ERANGE;
ret = __add_pages(nid, start_pfn, nr_pages, params);
- WARN_ON_ONCE(ret);
+ if (ret)
+ return ret;
/*
* Special case: add_pages() is called by memremap_pages() for adding device
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-10-01 12:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-01 8:15 [PATCH 1/1] x86/mm: fix spurious warning on __add_pages() failure Lance Yang
2026-10-01 9:12 ` Muchun Song
2026-10-01 9:43 ` David Hildenbrand (Arm)
2026-10-01 12:08 ` [tip: x86/mm] x86/mm: Fix " tip-bot2 for Lance Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®