Re: [PATCH 1/9] kho: Reclaim the metadata page left reserved after kexec
From: Pasha Tatashin
Date: Wed Nov 11 2026 - 17:37:05 EST
> 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")
Do we really need to apply this to stable? It behaves correctly, and
your patch performs a minor optimization by releasing a single page back
to the system.
> Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>
>
> 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 6f1f55fe3181..8a07783326a4 100644
> --- a/kernel/liveupdate/kexec_handover.c
> +++ b/kernel/liveupdate/kexec_handover.c
> @@ -1782,6 +1782,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);
> }
>
> /*
> @@ -1859,14 +1862,15 @@ static __init int kho_init(void)
> if (err)
> goto err_free_fdt;
>
> + if (fdt)
> + kho_in_debugfs_init(&kho_in.dbg, fdt);
> +
so add debugfs node here.
> err = kho_kexec_metadata_init(fdt);
Remove the kexec metadata node here. While this is somewhat unintuitive,
I do not see a better alternative.
> if (err)
> goto err_free_fdt;
>
> - if (fdt) {
> - kho_in_debugfs_init(&kho_in.dbg, fdt);
> + if (fdt)
> return 0;
> - }
>
> for (int i = 0; i < kho_bootmem_cnt; i++) {
> unsigned long base_pfn = PHYS_PFN(kho_bootmem[i].addr);
Reviewed-by: Pasha Tatashin <pasha.tatashin@xxxxxxxxxx>
--
Pasha