Re: [PATCH v2 4/7] kho: Expose rejected handovers that look like cold boots

From: Mike Rapoport

Date: Sun Nov 29 2026 - 16:03:48 EST


Hi Chris,

On Sat, Nov 28, 2026 at 10:27:38AM -0800, Chris Down wrote:
> Subject: [PATCH v2 4/7] kho: Expose rejected handovers that look like cold boots

Maybe

expose handover status in sysfs

> At Meta, our rollout needs to stop if the new kernel rejects the KHO
> handover. For example, if it doesn't recognise the handover FDT's
> compatible string, it can boot normally with all the preserved state
> lost. LUO's incoming/state reads "none", as on a cold boot. We log
> "disabling KHO revival", but our fleet collector reads procfs and sysfs
> and can't rely on kernel logs from every host.
>
> Let's add /sys/kernel/kho/incoming/state so the collector can tell a
> rejected handover from an ordinary boot. "revived" means the kernel
> accepted the handover and completed the preserved memory map walk. LUO
> reports the outcome of restoring sessions separately.
>
> KHO has no sysfs directory yet, so this adds /sys/kernel/kho in its own
> file, kho_sysfs.c. It is set up separately from kho_init(), because
> kho_init() returns early when KHO is disabled, and a rejected handover
> still needs to be reported then.
>
> Signed-off-by: Chris Down <chris@xxxxxxxxxxxxxx>
>
> diff --git a/kernel/liveupdate/kexec_handover.c b/kernel/liveupdate/kexec_handover.c


> @@ -1744,6 +1745,7 @@ err:

/* static void __init kho_mem_retrieve(void) */

> */
> kho_in.fdt_phys = 0;
> kho_in.radix_tree.root = NULL;
> + kho_in.state = KHO_INCOMING_FAILED;
> }
>
> static __init int kho_out_fdt_setup(void)
> @@ -1981,6 +1988,7 @@ err:
> */
> kho_in.fdt_phys = 0;
> kho_in.bootmem_phys = 0;
> + kho_in.state = KHO_INCOMING_FAILED;
> }
>
> void __init kho_memory_init(void)
> @@ -2079,6 +2087,7 @@ unmap_bootmem:

/* void __init kho_populate(phys_addr_t fdt_phys, ...) */

> unmap_fdt:
> early_memunmap(fdt, fdt_len);
> report:
> + kho_in.state = populated ? KHO_INCOMING_REVIVED : KHO_INCOMING_FAILED;

This is too early to say "REVIVED" here.

Although the state stays REVIVED unless we overwrite later with FAILED if
something goes wrong, I think it's better to make it explicit there.

Maybe even start with FAILED unconditionally in kho_populate() and only
reset it to REVIVED in kho_memory_init().

That way the state starts with NONE, then if kho_populate() is called we
know that's a KHO boot, and from there it's FAILED until proven otherwise.

This way we won't need to chase the points that should reset REVIVED to
FAILED after kho_populate() or check the current state before changing it.

> if (!populated)
> pr_warn("disabling KHO revival\n");
> }
> diff --git a/kernel/liveupdate/kexec_handover_internal.h b/kernel/liveupdate/kexec_handover_internal.h
> index e9685e1ef6d7..b559f5d43116 100644
> --- a/kernel/liveupdate/kexec_handover_internal.h
> +++ b/kernel/liveupdate/kexec_handover_internal.h
> @@ -22,6 +22,14 @@ struct kho_debugfs {};
> extern struct kho_bootmem *kho_bootmem;
> extern unsigned int kho_bootmem_cnt;
>
> +enum kho_incoming_state {
> + KHO_INCOMING_NONE,

This one is never set. Can we stick an explicit state = KHO_INCOMING_NONE
at the declaration of struct kho_in for clarity?

> + KHO_INCOMING_REVIVED,
> + KHO_INCOMING_FAILED,
> +};
> +
> +enum kho_incoming_state kho_in_state(void);
> +
> #ifdef CONFIG_KEXEC_HANDOVER_DEBUGFS
> int kho_debugfs_init(void);
> void kho_in_debugfs_init(struct kho_debugfs *dbg, const void *fdt);

--
Sincerely yours,
Mike.