Re: [PATCH v5 09/16] kexec: enable KHO support for memory preservation

From: Jason Gunthorpe
Date: Wed Apr 09 2025 - 11:38:22 EST


On Wed, Apr 09, 2025 at 04:58:16PM +0300, Mike Rapoport wrote:
> > I'm not sure that is consistent with what Matthew is trying to build,
> > I think we are trying to remove 'struct page' usage, especially for
> > compound pages. Right now, though it is confusing, folio is the right
> > word to encompass both page cache memory and random memdescs from
> > other subsystems.
>
> A disagree about random memdescs, just take a look at struct folio.

It is weird and confusing if you look too closely

> > I don't see we need two functions, folio should handle 0 order pages
> > just fine, and callers should generally be either not using struct
> > page at all or using their own memdesc/folio.
>
> struct folio is 4 struct pages. I don't see it suitable for order-0 pages
> at all.

It is used widely now for order 0 cases. There are lots of rules about
how the members of struct folio can be used, and one of them is you
can't exceed the 64 byte space for an order 0 allocation.

> > I think we still don't really know what will be needed, so I'd stick
> > with folio only as that allows building the memfd and a potential slab
> > preservation system.
>
> void * seems to me much more reasonable than folio one as the starting
> point because it allows preserving folios with the right order but it's not
> limited to it.

It would just call kho_preserve_folio() under the covers though.

> I don't mind having kho_preserve_folio() from day 1 and even stretching the
> use case we have right now to use it to preserve FDT memory.
>
> But kho_preserve_folio() does not make sense for reserve_mem and it won't
> make sense for vmalloc.

It does for vmalloc too, just stop thinking about it as a
folio-for-pagecache and instead as an arbitary order handle to buddy
allocator memory that will someday be changed to a memdesc :|

> The weird games slab does with casting back and forth to folio also seem to
> me like transitional and there won't be that folios in slab later.

Yes transitional, but we are at the transitional point and KHO should
fit in.

The lowest allocator primitive returns folios, which can represent any
order, and the caller casts to their own memdesc.

Later the lowest primitive will be to setup a memdesc and folio/others
will become much more logically split.

Jason