* [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 2/5] sh: remove unreachable memblock_reserve() return value check 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 2/5] sh: remove unreachable memblock_reserve() return value check
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, Yoshinori Sato, Rich Felker, John Paul Adrian Glaubitz
Cc: linux-mm, Sang-Heon Jeon, Ard Biesheuvel, Borislav Petkov,
Chris Zankel, Dave Hansen, Ingo Molnar, linux-kernel, linux-sh,
Madhavan Srinivasan, Max Filippov, Michael Ellerman,
Thomas Gleixner
reserve_crashkernel() runs from early_reserve_mem() in paging_init(),
before the same function calls memblock_allow_resize(). At that point
memblock_reserve() either succeeds or panics, never returning an error.
Therefore the return value check is unreachable, so remove it and the
related logic.
No functional change.
Signed-off-by: Sang-Heon Jeon <ekffu200098@gmail.com>
---
arch/sh/kernel/machine_kexec.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c
index 37073ca1e0ad..ba9c412f14d9 100644
--- a/arch/sh/kernel/machine_kexec.c
+++ b/arch/sh/kernel/machine_kexec.c
@@ -165,12 +165,7 @@ void __init reserve_crashkernel(void)
goto disable;
}
} else {
- ret = memblock_reserve(crashk_res.start, crash_size);
- if (unlikely(ret < 0)) {
- pr_err("crashkernel reservation failed - "
- "memory is in use\n");
- goto disable;
- }
+ memblock_reserve(crashk_res.start, crash_size);
}
crashk_res.end = crashk_res.start + crash_size - 1;
--
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 2/5] sh: remove unreachable memblock_reserve() return value check 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 2/5] sh: remove unreachable memblock_reserve() return value check 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