From: Pratyush Yadav <pratyush@kernel.org>
To: Chris Down <chris@chrisdown.name>
Cc: rppt@kernel.org, pasha.tatashin@soleen.com,
pratyush@kernel.org, graf@amazon.com,
kexec@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH v2 1/2] kho: skip bootmem setup in kho_init() if bootmem was inherited
Date: Wed, 02 Dec 2026 10:59:00 +0000 [thread overview]
Message-ID: <2vxzmrqouex7.fsf@kernel.org> (raw)
In-Reply-To: <ac61194cf889a29d390438b68ee9fd30e28d468b.1796126791.git.chris@chrisdown.name> (Chris Down's message of "Tue, 01 Dec 2026 22:32:09 -0800")
On Tue, Dec 01 2026, Chris Down wrote:
> On a cold boot, kho_reserve_bootmem() reserves the bootmem areas in
> memblock, and kho_init() later releases them to the page allocator as
> CMA. A kernel that was handed its bootmem areas by the previous kernel
> boots out of them instead. kho_init() must leave them alone.
>
> kho_init() tells the two cases apart by whether there is a handover
> FDT. That doesn't work if kho_mem_retrieve() fails. It clears
> kho_in.fdt_phys so that KHO users don't treat the boot as a KHO boot,
> but the bootmem areas are still the inherited ones. kho_init() would
> then run init_cma_reserved_pageblock() over memory that is in use.
>
> Nothing makes kho_mem_retrieve() fail at the moment, but the next
> patch does. Test kho_in.bootmem_phys instead, which is what
> kho_memory_init() uses to choose between retrieving the handover and
> reserving new bootmem areas.
>
> Signed-off-by: Chris Down <chris@chrisdown.name>
> ---
> kernel/liveupdate/kho_core.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/liveupdate/kho_core.c b/kernel/liveupdate/kho_core.c
> index 15fb892a4412..43ecef317cfd 100644
> --- a/kernel/liveupdate/kho_core.c
> +++ b/kernel/liveupdate/kho_core.c
> @@ -1928,10 +1928,16 @@ static __init int kho_init(void)
> if (err)
> goto err_free_fdt;
>
> - if (fdt) {
> + if (fdt)
> kho_in_debugfs_init(&kho_in.dbg, fdt);
> +
> + /*
> + * We've booted from the inherited bootmem. That means this kernel is
> + * already using it. As such, leave it alone even if the handover is
> + * dropped later.
Nit: I don't understand what "even if handover is dropped later" means.
Doesn't the handover get dropped _before_ kho_init()?
Also, perhaps "even if the handover fails" is better?
> + */
> + if (kho_in.bootmem_phys)
kho_memory_init_early() clears kho_in.bootmem_phys on failure. So this
doesn't work. It clears it because kho_memory_init() uses to check if it
should even try to retrieve preserved memory.
Perhaps it should only clear fdt_phys and kho_memory_init() should check
fdt_phys instead?
> return 0;
> - }
>
> for (int i = 0; i < kho_bootmem_cnt; i++) {
> unsigned long base_pfn = PHYS_PFN(kho_bootmem[i].addr);
--
Regards,
Pratyush Yadav
next prev parent reply other threads:[~2026-12-02 10:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 6:32 [PATCH v2 0/2] kho: handle failures to reserve preserved memory Chris Down
2026-12-02 6:32 ` [PATCH v2 1/2] kho: skip bootmem setup in kho_init() if bootmem was inherited Chris Down
2026-12-02 10:59 ` Pratyush Yadav [this message]
2026-12-02 6:32 ` [PATCH v2 2/2] kho: drop the handover if preserved memory can't be reserved Chris Down
2026-12-02 11:14 ` Pratyush Yadav
2026-12-02 11:24 ` [PATCH v2 0/2] kho: handle failures to reserve preserved memory Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2vxzmrqouex7.fsf@kernel.org \
--to=pratyush@kernel.org \
--cc=chris@chrisdown.name \
--cc=graf@amazon.com \
--cc=kernel-team@meta.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pasha.tatashin@soleen.com \
--cc=rppt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox