* [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot
@ 2026-07-06 16:37 Sang-Heon Jeon
2026-07-06 16:37 ` [PATCH v2 3/5] powerpc/fadump: remove unreachable memblock_reserve() return value checks Sang-Heon Jeon
2026-07-07 6:17 ` [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Mike Rapoport
0 siblings, 2 replies; 5+ messages in thread
From: Sang-Heon Jeon @ 2026-07-06 16:37 UTC (permalink / raw)
To: rppt, Ard Biesheuvel, Borislav Petkov, Chris Zankel, Dave Hansen,
Ingo Molnar, John Paul Adrian Glaubitz, Madhavan Srinivasan,
Max Filippov, Michael Ellerman, Rich Felker, Thomas Gleixner,
Yoshinori Sato
Cc: linux-mm, Sang-Heon Jeon, Christophe Leroy (CS GROUP),
H. Peter Anvin, Ilias Apalodimas, linux-efi, linux-kernel,
linuxppc-dev, linux-sh, Nicholas Piggin, x86
memblock_reserve() can only return an error after memblock_allow_resize()
has been called. Before that it either succeeds or panics, never returning
an error.
Before memblock_allow_resize() is called, the return value checks of
memblock_reserve() are unreachable and can be removed.
All the call sites are in different trees, so I split the change into one
patch per arch/subsystem. The patches are independent and can be applied
separately.
---
Changes from v1 [1]
- add reviewed-by tag
- rebased onto latest memblock for-next
[1] https://lore.kernel.org/all/20260616182959.2429774-1-ekffu200098@gmail.com/
---
Hello Mike,
Like the previous memblock cleanup series, could you review and take this patch series to the memblock tree?
Thank you for taking valuable time.
Best Regards,
Sang-Heon Jeon
---
Sang-Heon Jeon (5):
x86/setup: remove unreachable memblock_reserve() return value check
sh: remove unreachable memblock_reserve() return value check
powerpc/fadump: remove unreachable memblock_reserve() return value
checks
xtensa: remove unreachable memblock_reserve() return value checks
Revert "tpm: do not ignore memblock_reserve return value"
arch/powerpc/kernel/fadump.c | 14 +++-----------
arch/sh/kernel/machine_kexec.c | 7 +------
arch/x86/kernel/setup.c | 7 ++-----
arch/xtensa/kernel/setup.c | 13 +++++++------
drivers/firmware/efi/tpm.c | 7 +------
5 files changed, 14 insertions(+), 34 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 3/5] powerpc/fadump: remove unreachable memblock_reserve() return value checks 2026-07-06 16:37 [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Sang-Heon Jeon @ 2026-07-06 16:37 ` Sang-Heon Jeon 2026-07-07 6:17 ` [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Mike Rapoport 1 sibling, 0 replies; 5+ messages in thread From: Sang-Heon Jeon @ 2026-07-06 16:37 UTC (permalink / raw) To: rppt, Madhavan Srinivasan, Michael Ellerman Cc: linux-mm, Sang-Heon Jeon, Ard Biesheuvel, Borislav Petkov, Christophe Leroy (CS GROUP), Chris Zankel, Dave Hansen, Ingo Molnar, John Paul Adrian Glaubitz, linux-kernel, linuxppc-dev, Max Filippov, Nicholas Piggin, Rich Felker, Thomas Gleixner, Yoshinori Sato, Mukesh Kumar Chaurasiya fadump_append_bootargs() and fadump_reserve_mem() both run from early_init_devtree(), before it calls memblock_allow_resize(). At that point memblock_reserve() either succeeds or panics, never returning an error. Therefore the return value checks are unreachable, so remove them and the related logic. No functional change. Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com> Reviewed-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com> --- arch/powerpc/kernel/fadump.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 7f79c9aea4a9..1629a82b9528 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -154,13 +154,8 @@ void __init fadump_append_bootargs(void) if (!fw_dump.dump_active || !fw_dump.param_area_supported || !fw_dump.param_area) return; - if (fw_dump.param_area < fw_dump.boot_mem_top) { - if (memblock_reserve(fw_dump.param_area, COMMAND_LINE_SIZE)) { - pr_warn("WARNING: Can't use additional parameters area!\n"); - fw_dump.param_area = 0; - return; - } - } + if (fw_dump.param_area < fw_dump.boot_mem_top) + memblock_reserve(fw_dump.param_area, COMMAND_LINE_SIZE); append_args = (char *)fw_dump.param_area; len = strlen(boot_command_line); @@ -632,10 +627,7 @@ int __init fadump_reserve_mem(void) (fw_dump.ops->fadump_setup_metadata(&fw_dump) < 0)) goto error_out; - if (memblock_reserve(base, size)) { - pr_err("Failed to reserve memory!\n"); - goto error_out; - } + memblock_reserve(base, size); pr_info("Reserved %lldMB of memory at %#016llx (System RAM: %lldMB)\n", (size >> 20), base, (memblock_phys_mem_size() >> 20)); -- 2.43.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot 2026-07-06 16:37 [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Sang-Heon Jeon 2026-07-06 16:37 ` [PATCH v2 3/5] powerpc/fadump: remove unreachable memblock_reserve() return value checks Sang-Heon Jeon @ 2026-07-07 6:17 ` Mike Rapoport 2026-07-07 13:24 ` Sang-Heon Jeon 1 sibling, 1 reply; 5+ messages in thread From: Mike Rapoport @ 2026-07-07 6:17 UTC (permalink / raw) To: Sang-Heon Jeon Cc: Ard Biesheuvel, Borislav Petkov, Chris Zankel, Dave Hansen, Ingo Molnar, John Paul Adrian Glaubitz, Madhavan Srinivasan, Max Filippov, Michael Ellerman, Rich Felker, Thomas Gleixner, Yoshinori Sato, linux-mm, Christophe Leroy (CS GROUP), H. Peter Anvin, Ilias Apalodimas, linux-efi, linux-kernel, linuxppc-dev, linux-sh, Nicholas Piggin, x86 Hi Sang-Heon, On Tue, Jul 07, 2026 at 01:37:48AM +0900, Sang-Heon Jeon wrote: > memblock_reserve() can only return an error after memblock_allow_resize() > has been called. Before that it either succeeds or panics, never returning > an error. > > Before memblock_allow_resize() is called, the return value checks of > memblock_reserve() are unreachable and can be removed. I'd rather keep these checks. Removing them relies on internal details of memblock_reserve() implementation and the existing event sequence. If the code would move around relying on panic in memblock_reserve() may not be correct. And the few bytes and cycles the change saves do not worth the churn. -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot 2026-07-07 6:17 ` [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Mike Rapoport @ 2026-07-07 13:24 ` Sang-Heon Jeon 2026-07-07 13:40 ` Mike Rapoport 0 siblings, 1 reply; 5+ messages in thread From: Sang-Heon Jeon @ 2026-07-07 13:24 UTC (permalink / raw) To: Mike Rapoport Cc: Ard Biesheuvel, Borislav Petkov, Chris Zankel, Dave Hansen, Ingo Molnar, John Paul Adrian Glaubitz, Madhavan Srinivasan, Max Filippov, Michael Ellerman, Rich Felker, Thomas Gleixner, Yoshinori Sato, linux-mm, Christophe Leroy (CS GROUP), H. Peter Anvin, Ilias Apalodimas, linux-efi, linux-kernel, linuxppc-dev, linux-sh, Nicholas Piggin, x86 Hi Mike, On Tue, Jul 7, 2026 at 3:17 PM Mike Rapoport <rppt@kernel.org> wrote: > > Hi Sang-Heon, > > On Tue, Jul 07, 2026 at 01:37:48AM +0900, Sang-Heon Jeon wrote: > > memblock_reserve() can only return an error after memblock_allow_resize() > > has been called. Before that it either succeeds or panics, never returning > > an error. > > > > Before memblock_allow_resize() is called, the return value checks of > > memblock_reserve() are unreachable and can be removed. > > I'd rather keep these checks. > > Removing them relies on internal details of memblock_reserve() implementation > and the existing event sequence. If the code would move around relying on > panic in memblock_reserve() may not be correct. > > And the few bytes and cycles the change saves do not worth the churn. Makes sense to me. But most early boot callers of memblock_reserve() don't check the return value, so I thought we already rely on its internal behavior anyway. So the few remaining checks just looked a bit inconsistent to me. Would you still prefer to keep these checks? If so, I'm fine with dropping this patch series. It's not a big deal :) Thank you for taking the time to review this series. > -- > Sincerely yours, > Mike. Best Regards, Sang-Heon Jeon ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot 2026-07-07 13:24 ` Sang-Heon Jeon @ 2026-07-07 13:40 ` Mike Rapoport 0 siblings, 0 replies; 5+ messages in thread From: Mike Rapoport @ 2026-07-07 13:40 UTC (permalink / raw) To: Sang-Heon Jeon Cc: Ard Biesheuvel, Borislav Petkov, Chris Zankel, Dave Hansen, Ingo Molnar, John Paul Adrian Glaubitz, Madhavan Srinivasan, Max Filippov, Michael Ellerman, Rich Felker, Thomas Gleixner, Yoshinori Sato, linux-mm, Christophe Leroy (CS GROUP), H. Peter Anvin, Ilias Apalodimas, linux-efi, linux-kernel, linuxppc-dev, linux-sh, Nicholas Piggin, x86 On Tue, Jul 07, 2026 at 10:24:09PM +0900, Sang-Heon Jeon wrote: > Hi Mike, > > On Tue, Jul 7, 2026 at 3:17 PM Mike Rapoport <rppt@kernel.org> wrote: > > > > Hi Sang-Heon, > > > > On Tue, Jul 07, 2026 at 01:37:48AM +0900, Sang-Heon Jeon wrote: > > > memblock_reserve() can only return an error after memblock_allow_resize() > > > has been called. Before that it either succeeds or panics, never returning > > > an error. > > > > > > Before memblock_allow_resize() is called, the return value checks of > > > memblock_reserve() are unreachable and can be removed. > > > > I'd rather keep these checks. > > > > Removing them relies on internal details of memblock_reserve() implementation > > and the existing event sequence. If the code would move around relying on > > panic in memblock_reserve() may not be correct. > > > > And the few bytes and cycles the change saves do not worth the churn. > > Makes sense to me. > > But most early boot callers of memblock_reserve() don't check the > return value, so I thought we already rely on its internal behavior > anyway. So the few remaining checks just looked a bit inconsistent to > me. In reality it's very unlikely for memblock_reserve() to fail, especially after resize is allowed. And if it does fail, the system would trip on a memory error, usually sooner than later. > Would you still prefer to keep these checks? If so, I'm fine with > dropping this patch series. It's not a big deal :) Let's keep the checks as they are now. > Best Regards, > Sang-Heon Jeon -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-07 13:40 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-06 16:37 [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Sang-Heon Jeon 2026-07-06 16:37 ` [PATCH v2 3/5] powerpc/fadump: remove unreachable memblock_reserve() return value checks Sang-Heon Jeon 2026-07-07 6:17 ` [PATCH v2 0/5] treewide: remove unreachable memblock_reserve() return value checks in early boot Mike Rapoport 2026-07-07 13:24 ` Sang-Heon Jeon 2026-07-07 13:40 ` Mike Rapoport
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox