On Fri, Oct 24 2025, Mike Rapoport wrote:

> On Wed, Oct 22, 2025 at 01:01:08PM +0200, Pratyush Yadav wrote:
>> Hi Pasha,
>> 
>> On Tue, Oct 21 2025, Pasha Tatashin wrote:
>> 
>> > From: "Mike Rapoport (Microsoft)" <[email protected]>
>> >
>> > The KHO framework uses a notifier chain as the mechanism for clients to
>> > participate in the finalization process. While this works for a single,
>> > central state machine, it is too restrictive for kernel-internal
>> > components like pstore/reserve_mem or IMA. These components need a
>> > simpler, direct way to register their state for preservation (e.g.,
>> > during their initcall) without being part of a complex,
>> > shutdown-time notifier sequence. The notifier model forces all
>> > participants into a single finalization flow and makes direct
>> > preservation from an arbitrary context difficult.
>> > This patch refactors the client participation model by removing the
>> > notifier chain and introducing a direct API for managing FDT subtrees.
>> >
>> > The core kho_finalize() and kho_abort() state machine remains, but
>> > clients now register their data with KHO beforehand.
>> >
>
> ...
>
>> > @@ -1280,7 +1298,7 @@ static __init int kho_init(void)
>> >    kho_enable = false;
>> >    return err;
>> >  }
>> > -late_initcall(kho_init);
>> > +fs_initcall(kho_init);
>> 
>> Is this change related to this patch? Also, why fs_initcall?
>
> memblock registers sub-fdt in late_initcall(), so we should have the root
> fdt ready by then. 

I see. Should this be even earlier then? Other components might also
depend on KHO being initialized, and those might be at or before
fs_initcall.

For example, LUO does its init using early_initcall and uses KHO, even
before it is initialized [0]. This works because kho_retrieve_subtree()
only uses parts initialized very early in boot (the KHO FDT), but I
suppose we want to have a proper initialization order to not rely on
things that just happen to work until they don't.

Since kho_init() has a dependency on debugfs, which gets initialized in
core_initcall, I guess the earliest it can be is postcore_initcall. Or,
we split out the debugfs parts into a separate init function (they have
their own file anyway) and initialize "core KHO" in early_initcall? Then
LUO can be in core_initcall and all its users in later ones.

Thoughts?

[0] 
https://lore.kernel.org/lkml/[email protected]/

-- 
Regards,
Pratyush Yadav

Reply via email to