Re: [RFC v2 05/16] luo: luo_core: integrate with KHO

From: Pasha Tatashin
Date: Mon Jun 23 2025 - 07:30:01 EST


On Mon, Jun 23, 2025 at 3:32 AM Mike Rapoport <rppt@xxxxxxxxxx> wrote:
>
> On Wed, Jun 18, 2025 at 01:43:18PM -0400, Pasha Tatashin wrote:
> > On Wed, Jun 18, 2025 at 1:00 PM Pasha Tatashin
> >
> > So currently, KHO provides the following two types of internal API:
> >
> > Preserve memory and metadata
> > =========================
> > kho_preserve_folio() / kho_preserve_phys()
> > kho_unpreserve_folio() / kho_unpreserve_phys()
> > kho_restore_folio()
> >
> > kho_add_subtree() kho_retrieve_subtree()
> >
> > State machine
> > ===========
> > register_kho_notifier() / unregister_kho_notifier()
> >
> > kho_finalize() / kho_abort()
> >
> > We should remove the "State machine", and only keep the "Preserve
> > Memory" API functions. At the time these functions are called, KHO
> > should do the magic of making sure that the memory gets preserved
> > across the reboot.
> >
> > This way, reserve_mem_init() would call: kho_preserve_folio() and
> > kho_add_subtree() during boot, and be done with it.
>
> I agree that there's no need in notifiers.
>
> I even have a half cooked patch for this on top of "kho: allow to drive kho
> from within kernel"
>
> From 02716e4731480bde997a9c1676b7246aa8e358de Mon Sep 17 00:00:00 2001
> From: "Mike Rapoport (Microsoft)" <rppt@xxxxxxxxxx>
> Date: Sun, 22 Jun 2025 14:37:17 +0300
> Subject: [PATCH] kho: drop notifiers
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> ---
> include/linux/kexec_handover.h | 27 +-------
> kernel/kexec_handover.c | 114 ++++++++++++++-----------------
> kernel/kexec_handover_debug.c | 3 +-
> kernel/kexec_handover_internal.h | 3 +-
> mm/memblock.c | 56 +++------------
> 5 files changed, 65 insertions(+), 138 deletions(-)
>
> diff --git a/include/linux/kexec_handover.h b/include/linux/kexec_handover.h
> index f98565def593..ac9cb6eae71f 100644
> --- a/include/linux/kexec_handover.h
> +++ b/include/linux/kexec_handover.h
> @@ -10,14 +10,7 @@ struct kho_scratch {
> phys_addr_t size;
> };
>
> -/* KHO Notifier index */
> -enum kho_event {
> - KEXEC_KHO_FINALIZE = 0,
> - KEXEC_KHO_ABORT = 1,
> -};
> -
> struct folio;
> -struct notifier_block;
>
> #define DECLARE_KHOSER_PTR(name, type) \
> union { \
> @@ -36,20 +29,15 @@ struct notifier_block;
> (typeof((s).ptr))((s).phys ? phys_to_virt((s).phys) : NULL); \
> })
>
> -struct kho_serialization;
> -
> #ifdef CONFIG_KEXEC_HANDOVER
> bool kho_is_enabled(void);
>
> int kho_preserve_folio(struct folio *folio);
> int kho_preserve_phys(phys_addr_t phys, size_t size);
> struct folio *kho_restore_folio(phys_addr_t phys);
> -int kho_add_subtree(struct kho_serialization *ser, const char *name, void *fdt);
> +int kho_add_subtree(const char *name, void *fdt);

For completeness, we also need `void kho_remove_substree(const char
*name);`, currently, all trees are removed during kho_abort(). Let's
rebase and include this patch on top of the next version of LUO, that
we are exchanging off list, and send it together later this week.

Thanks,
Pasha