Re: [PATCH 1/9] kho: Reclaim the metadata page left reserved after kexec

From: Pasha Tatashin

Date: Thu Nov 19 2026 - 09:55:38 EST


On Wed Nov 11, 2026 at 2:52 AM EST, Chris Down wrote:
> After a KHO kexec, the new kernel keeps the page holding the previous
> kernel's kexec metadata reserved for as long as it runs. It only needs
> the page once, since kho_in_kexec_metadata() copies the previous release
> and the kexec count out of it at boot, and nothing reads it again.
>
> Free it with kho_restore_free() once copying is complete.
>
> Fixes: 76aa46b9e404 ("kho: kexec-metadata: track previous kernel chain")
> Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>
> ---
> Documentation/admin-guide/mm/kho.rst | 4 +++-
> kernel/liveupdate/kexec_handover.c | 10 +++++++---
> 2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/admin-guide/mm/kho.rst b/Documentation/admin-guide/mm/kho.rst
> index 902d171a780a..f9d2cc5999ee 100644
> --- a/Documentation/admin-guide/mm/kho.rst
> +++ b/Documentation/admin-guide/mm/kho.rst
> @@ -120,4 +120,6 @@ stabilized.
>
> ``/sys/kernel/debug/kho/in/sub_fdts/``
> Similar to ``kho/out/sub_fdts/``, but contains sub blobs
> - of KHO producers passed from the old kernel.
> + of KHO producers passed from the old kernel. A blob disappears
> + once the kernel has read and freed it, as ``kexec-metadata`` does
> + during boot.
> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c
> index eeec298aa9d6..3046b89e5db4 100644
> --- a/kernel/liveupdate/kexec_handover.c
> +++ b/kernel/liveupdate/kexec_handover.c
> @@ -1808,6 +1808,9 @@ static void __init kho_in_kexec_metadata(void)
>
> pr_info("exec from: %s (count %u)\n",
> kho_in.previous_release, kho_in.kexec_count);
> +
> + kho_debugfs_blob_remove(&kho_in.dbg, metadata);
> + kho_restore_free(metadata);
> }
>
> /*
> @@ -1885,14 +1888,15 @@ static __init int kho_init(void)
> if (err)
> goto err_free_fdt;
>
> + if (fdt)
> + kho_in_debugfs_init(&kho_in.dbg, fdt);
> +
> err = kho_kexec_metadata_init(fdt);
> if (err)
> goto err_free_fdt;
>
> - if (fdt) {
> - kho_in_debugfs_init(&kho_in.dbg, fdt);
> + if (fdt)
> return 0;
> - }

This re-ordering can be removed, now that we applied:
https://lore.kernel.org/all/179508700586.361583.12491114908870226409.b4-ty@b4/

>
> for (int i = 0; i < kho_bootmem_cnt; i++) {
> unsigned long base_pfn = PHYS_PFN(kho_bootmem[i].addr);





--
Pasha