Re: [PATCH] block: partitions: replace __get_free_page() with kmalloc()
From: Matthew Wilcox
Date: Tue May 26 2026 - 10:42:55 EST
On Tue, May 26, 2026 at 02:07:36PM +0200, Vlastimil Babka wrote:
> The main reasons for switching AFAIU would be related with the
> folio/memdesc conversions? If one needs just a kernel memory buffer,
> kmalloc() it is, even if it happens to be page size. Page allocator
> should be only used if you need e.g. the refcounting or anything else
> that struct page provides. But then in some cases the memdesc conversion
> would need adjustments at some point. With kmalloc() we can forget about
> this user.
No, I think this is unrelated to memdescs.
I've seen a few people say slightly wrong things about
folios/pages/memdescs recently, so let me try to clarify the end state.
I do not intend to get rid of the ability to allocate a bare page of
memory with something like alloc_pages() or get_free_page(). It's
just that the struct page associated with it will contain far less
information (because it's smaller).
https://kernelnewbies.org/MatthewWilcox/Memdescs has a bit more
information, but to distill it:
You get a u64 worth of data (technically one per page, but if you
allocate multiple pages, they're all going to be the same).
Bits 0-3 will be type 0 (to indicate that it has no memdesc).
Bits 4-10 will be subtype 2 (to indicate no information about owner).
Bit 11 will be clear to indicate that this page should not be mappable
to userspace.
Bits 12-17 will store the allocation order.
The top few bits will encode zone/node/section like page->flags
do today.
That doesn't leave many free bits for the user, but that's OK because
most allocations don't actually need any bits in struct page. If you do
want something like a refcount or list_head, see the "Managed memory"
section on that page. If you actually want a full-fat folio, well,
allocate a folio, not a page.