[PATCH v4 18/19] mm: memfd_luo: Add feature header to struct memfd_luo_folio_ser

Pratyush Yadav pratyush at kernel.org
Wed Dec 2 03:30:11 PST 2026


On Wed, Dec 02 2026, tarunsahu at google.com wrote:

> Pratyush Yadav <pratyush at kernel.org> writes:
>
>> On Tue, Nov 10 2026, Tarun Sahu wrote:
>>
>>> Precede each serialized folio entry in the preserved memfd folio array
>>> with struct kho_ser_hdr via DECLARE_KHO_SER so future per-folio memfd
>>> features can append fields to struct memfd_luo_folio_ser without breaking
>>> compatibility between adjacent kernels.
>>>
>>> Allocate the preserved folio array using kho_ser_size(memfd_luo_folio_ser)
>>> per entry and initialize each entry feature header in
>>> memfd_luo_preserve_folios(). On the incoming path in
>>> memfd_luo_discard_folios() and memfd_luo_retrieve_folios(), validate each
>>> entry feature header with kho_ser_validate() and advance between entries
>>> using fhdr->size so entries written with a different feature layout are
>>> traversed accurately.
>>
>> No. The flags in each folio entry is a part of memfd's ABI. These flags
>> don't have an ABI of their own. If the layout of memfd_luo_folio_ser
>> changes, it goes in the memfd_luo_ser flags.
>>
>> Doubling the memory needed to preserve a memfd is not acceptable.
>
> Based on recent discussion in hypervisor liveupdate meeting, we decided to omit
> the kho_ser_hdr for collection entries and we will handle any changes to
> their ABI by their parent structure. So for pci_dev_ser changes will be
> handled by pci_ser feature header. and similarly memfd_luo_folio_ser
> changes will be handled by memfd_luo_ser which is aligning with your
> comment above.
>
> I want to discuss on this approach, same I raised here [1]
>
> collection entry that are allocated by kho_block can easily be
> deserialized as kho block layer has entry_size that is also handed over
> by previous kernel hence the current kernel can deserialize those
> entries based on entry_size. There are no problem in this. (even
> rollback is safe as well)
>
> Collection entries that are allocated by kho_vmalloc, are part of an
> array which resides inside a folio of order (= # of folios * sizeof(memfd_luo_folio_ser)).
> During time of deserialization, kho_restore_vmalloc will just give the
> array of pages (a folio) that should be deserialized in array of
> collection entry which is memfd_luo_folio_ser, direct type cast with +1
> in loop will not work as the size of memfd_luo_folio_ser might differ
> across kernel. So, Like I suggested to have collection entry size in the
> parent structure (folio_ser_entry_size) is acceptable design here?

ABI contract should be to _not_ change the size of memfd_luo_folio_ser
at all. It is always 16 bytes, and if you need more, you need to make a
breaking ABI change (that is, a required flag).

>
> struct memfd_luo_ser {
>
>        ...
>        <kho_vmalloc ptr>
>        u64 folio_ser_entry_size;

No, I'd much rather we do a feature flag as a follow up if we need this.
All this is going to go away with KHO map [0] anyway, so not really a
problem worth solving right now.

[0] https://lore.kernel.org/kexec/20261116134013.1636689-6-pratyush@kernel.org/

-- 
Regards,
Pratyush Yadav



More information about the linux-arm-kernel mailing list