From: Pasha Tatashin <pasha.tatashin@soleen.com>
To: Mike Rapoport <rppt@kernel.org>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>,
linux-kselftest@vger.kernel.org, shuah@kernel.org,
akpm@linux-foundation.org, linux-mm@kvack.org,
skhan@linuxfoundation.org, linux-doc@vger.kernel.org,
jasonmiu@google.com, linux-kernel@vger.kernel.org,
corbet@lwn.net, ran.xiaokai@zte.com.cn,
kexec@lists.infradead.org, pratyush@kernel.org, graf@amazon.com
Subject: Re: [RFC v1 0/9] kho: granular compatibility and header decoupling
Date: Sun, 7 Jun 2026 13:43:09 +0000 [thread overview]
Message-ID: <aiVp5RlbWRz5VnPB@plex> (raw)
In-Reply-To: <178083348872.1648214.17778188633648887952.b4-review@b4>
On 06-07 14:58, Mike Rapoport wrote:
> On Fri, 05 Jun 2026 03:32:26 +0000, Pasha Tatashin <pasha.tatashin@soleen.com> wrote:
>
> Hi,
>
> > [...]
> > data structure. Keeping all of this within the same `kexec_handover.c`
> > file, and also under the same global version, is no longer sustainable.
> >
> > To address this, this series:
> > 1. Refactors and reorganizes the code by splitting out radix tree
> > and vmalloc into separate files.
>
> I'd keep vmalloc where it is, it's more of a memory preservation primitive
> rather than a data structure of it's own. The data structure it uses is an
> implementation detail.
kho vmalloc is absolutely a data structure. KHO core only provides the
basic handover mechanism (FDT nodes, physical memory ranges). vmalloc
is a structured representation on top of KHO, and should provide its own
versioned ABI.
If we change any of the vmalloc serialized structures (like kho_vmalloc,
kho_vmalloc_chunk, or kho_vmalloc_hdr), then vmalloc won't work and
compatibility will break.
Core KHO does not need vmalloc; nothing in kexec_handover.c uses it.
Instead, vmalloc has external customers:
- memfd (uses it to preserve serialized folio metadata)
- KHO test suite in lib/test_kho.c (uses it to preserve physical address arrays)
> Let's minimize the churn where possible for the sake of git blame and
> backports.
It is much better to do the right cleanups now while KHO is young. Once more
subsystems are added, this refactoring will be twice as hard. Modularizing the
code now guarantees a simpler, safer, and scalable design. Placing each data
structure in its own file gives us code that is easier to maintain, review, and
less prone to bugs.
> > 2. Moves and organizes internal and ABI headers into structured
> > directories under include/linux/kho/ and include/linux/kho/abi/.
> > Instead of cluttering include/linux/ with prefix-styled headers like
> > kho_block.h or kho_radix_tree.h, we use the already existing
> > include/linux/kho/ directory (e.g., kho/block.h and
> > kho/radix_tree.h).
>
> This looks to me like unnecessary churn.
> These all are bundled with KHO anyway, there is no header dependencies
> that justify small headers for each two functions and netiher
> linux/kexec_handover.h nor linux/kho/abi/kexec_handover.h are that long
> to start splitting them.
External users only need to include the headers they actually use. For
example, LUO shouldn't have to pull vmalloc or radix tree KHO
declarations, and memfd does not need block.
From a maintenance point of view, it is much easier to catch ABI
changes when the file with the appropriate version has been changed,
and most likely the version of that file should be updated. If a single
header contains compatibility versions for several different data
structures, it is easier to miss the correct version update.
Since we are splitting the source files (like kho_radix.c and
kho_vmalloc.c), the headers should logically follow the same
modularity.
>
> > 3. Introduces a standard set of compatibility helpers in
> > kho/abi/compat.h.
> > 4. Decouples the compatibility strings of individual KHO subsystems
> > (radix tree, vmalloc, and block) from the global KHO version.
> > This enables independent, granular compatibility versioning.
>
> I agree that we should decouple versioning of these components from the
> global KHO versioning.
> Can't say I agree with the way you propose to do it.
>
> I don't like that each user of a KHO component should include that
> component version in its own version string (or whatever it may become
> later).
>
> It requires ABI headers update each time a user decides to add a new
> data structure and worse when there is a change to that data structure.
> It creates coupling of the data structure user with its particular
> version and just looks ugly IMHO.
It is actually the opposite.
If a user adds a new data structure, that new data structure will have
its own compatibility version. Instead of the current approach where
the global version string needs to be updated, only the new version
string would be added.
Also, if someone updates their code to use the new data structure, their
compatibility string is going to be updated anyway, as part of using
the data structure requires including the dependency in their
compatibility.
> Suppose we added new fields to vmalloc, but made the implementation of
> restore to be able to cope with both old and new versions.
> How this would be reflected in memfd versioning?
> We'll add both versions of vmalloc to memfd version? And all other vmalloc
> users?
Backward compatibility is not in scope at the moment, but we can make
the version parsing more granular in the future.
Instead of a simple strncmp(), we can introduce a standard callback
interface for data structures. Each data structure implementation would
implement this interface, and we would pass the parsed version string
to the data-structure-specific version check.
> Or, say, we add support to kmalloc() and use it in kho_block.
> Then we'd have to add kmalloc() versioning to all kho_block users, right?
I was thinking about this. Since we don't have examples of data
structures depending on each other right now, I simply made sure
there are no duplicates in the compatibility strings.
If data structures have interdependencies in the future, we can easily
remove this uniqueness restriction. The users of block will still
include the block compatibility string (which automatically includes
kmalloc), and if user also depends on kmalloc, they will include it
as well.
> I think the versioning of each component should be handled by ->restore()
> of that component. If it sees an incompatible version in the preserved
> data, it returns an error. The versions can be stored e.g. in the base KHO
> fdt.
Hm, I think, checking compatibility inside ->restore() of each component may be
too late in the boot sequence.
By checking the composite compatibility strings upfront (before invoking
the actual restore/retrieve callbacks), we can guarantee that the entire
state configuration is fully compatible. If any mismatch is found, we
can cleanly abort the live update.
Additionally, keeping the versioning managed via composite strings on the
serialized data and registered handlers keeps the KHO core completely
decoupled from individual component ABIs, avoiding the need to bloat the
base KHO FDT with subsystem-specific versions.
> > 5. Adds a KUnit test suite to verify that the composite compatibility
> > strings of different subsystems remain unique and sorted in
> > alphabetical order, guaranteeing a consistent and predictable
> > representation across configurations.
>
> Without "composite compatibility strings" we don't need to care about
> them "remaining unique and sorted in alphabetical order".
These are not strict runtime requirements; they are simply there to enforce
code cleanliness and prevent human errors like accidental duplicates or
mismatched orders.
Even with a simple strncmp(), it works perfectly fine as long as the
strings match exactly. If the uniqueness or sorting constraints are too
strict, they can easily be removed.
In the future, we can transition to a more sophisticated version checker
that parses the composite string into individual subsystem version tokens
and verifies them one-by-one, rather than relying on a strict literal
strcmp() string comparison.
> The need for this test alone is already a red flag ;-)
I will remove test ;-)
prev parent reply other threads:[~2026-06-07 13:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 3:32 [RFC v1 0/9] kho: granular compatibility and header decoupling Pasha Tatashin
2026-06-05 3:32 ` [RFC v1 1/9] kho: split out radix tree tracker into kho_radix.c Pasha Tatashin
2026-06-07 11:58 ` Mike Rapoport
2026-06-07 16:20 ` Pasha Tatashin
2026-06-07 17:59 ` Mike Rapoport
2026-06-05 3:32 ` [RFC v1 2/9] kho: split radix tree headers out of kexec_handover.h Pasha Tatashin
2026-06-05 3:32 ` [RFC v1 3/9] kho: split out vmalloc preservation into kho_vmalloc.c Pasha Tatashin
2026-06-05 3:32 ` [RFC v1 4/9] kho: split vmalloc headers out of kexec_handover.h Pasha Tatashin
2026-06-05 3:32 ` [RFC v1 5/9] kho: move kho_block.h to kho/block.h Pasha Tatashin
2026-06-05 3:32 ` [RFC v1 6/9] kho: introduce compatibility helpers and decouple block version Pasha Tatashin
2026-06-05 3:32 ` [RFC v1 7/9] kho: decouple radix tree compatibility from global KHO version Pasha Tatashin
2026-06-05 3:32 ` [RFC v1 8/9] kho: decouple vmalloc compatibility from global KHO version and update memfd Pasha Tatashin
2026-06-05 3:32 ` [RFC v1 9/9] liveupdate: add KUnit test to verify alphabetical order of compatibility strings Pasha Tatashin
2026-06-07 11:58 ` [RFC v1 0/9] kho: granular compatibility and header decoupling Mike Rapoport
2026-06-07 13:43 ` Pasha Tatashin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aiVp5RlbWRz5VnPB@plex \
--to=pasha.tatashin@soleen.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=graf@amazon.com \
--cc=jasonmiu@google.com \
--cc=kexec@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pratyush@kernel.org \
--cc=ran.xiaokai@zte.com.cn \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox