Re: [PATCH v4 05/19] kho: Add feature header for fine-grained ABI compatibility
From: Mike Rapoport
Date: Sun Nov 15 2026 - 13:01:59 EST
On Tue, Nov 10, 2026 at 05:01:48AM +0000, Tarun Sahu wrote:
>
> Each subsystem registers its serialized structure with:
>
> DECLARE_KHO_SER(name, payload_size, nr_required, nr_optional)
>
> This establishes compile-time assertions and provides type-checked
> helpers: kho_ser_size() for total allocation size, kho_ser_init() to
> initialize the header, kho_ser_payload() to access the typed payload at
> its dynamic offset, and kho_ser_validate() to validate required features
> during restoration. DECLARE_KHO_SER_HDR(name, *fhdr) declares a struct
> kho_ser_hdr pointer while verifying at compile time that name was
> registered with DECLARE_KHO_SER(), allowing callers to document which
> structure a feature header pointer represents.
>
> An example demonstrating how a hypothetical structure defines its
> features:
>
> enum foo_ser_required {
> FOO_SER_REQ_BAR,
> __FOO_SER_NR_REQUIRED,
> };
>
> enum foo_ser_optional {
> FOO_SER_OPT_BAZ,
> __FOO_SER_NR_OPTIONAL,
> };
>
> struct foo_ser {
> __u64 base; /* base fields, always present */
> __u64 bar; /* FOO_SER_REQ_BAR */
> __u64 baz; /* FOO_SER_OPT_BAZ */
> };
>
> DECLARE_KHO_SER(foo_ser, 24,
The example should have included 7 fields total to make it 42 ;-)
Seriously, this magic number show must stop.
> __FOO_SER_NR_REQUIRED, __FOO_SER_NR_OPTIONAL);
>
--
Sincerely yours,
Mike.