Re: [PATCH v4 03/19] kho, memfd_luo: Reference struct kho_vmalloc via serialized pointer

From: Pratyush Yadav

Date: Thu Nov 26 2026 - 11:36:15 EST


On Wed, Nov 25 2026, David Matlack wrote:

> On Wed Nov 25, 2026 at 6:43 AM PST, Pratyush Yadav wrote:
> [...]
>
>> So I wouldn't want to support slab until we have file handlers that
>> churn through a lot of preserved objects.
>
> Makes sense. If KHO slab isn't coming, then I'm fine with the arena.
>
> One thing I realized is that the choice between the two is visible to
> the incoming kernel. With separate allocations, the incoming kernel has
> to free struct kho_vmalloc and struct memfd_luo_ser separately. With
> the arena, it must only free the top-level allocation. So we should
> pick one now (while memfd is bumping its compatible string anyway)
> rather than switching later.
>
> Separate allocations leaves the door open to KHO slab but wastes memory
> in the short term. It's not obvious to me which direction to go :)

Separate allocations aren't any more flexible than arena allocations.
Even if you have separate allocations, you need to know how they were
allocated to be able to free them. If they came from slab, you need to
call kmem_cache_free(), if they came from kho_alloc_preserve(), you need
to call kho_restore_free().

So you need to store the information of their origin somewhere, probably
in a feature flag. Same goes for arena. If we ever want to move away
from arena, we'd have to use a feature flag.

So to me, I think they are about the same in flexibility. Using separate
allocations is a tiny bit easier, arena is a tiny bit more efficient.
Which is why I like arena mode.

--
Regards,
Pratyush Yadav