From: Vlastimil Babka <vbabka@suse.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Mike Rapoport <rppt@kernel.org>,
Christoph Hellwig <hch@infradead.org>,
Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] block: partitions: replace __get_free_page() with kmalloc()
Date: Tue, 26 May 2026 22:57:13 +0200 [thread overview]
Message-ID: <8b780901-8184-4908-8bda-56fac42fe6b3@suse.com> (raw)
In-Reply-To: <ahWwD0eqj3cUgaKn@casper.infradead.org>
On 5/26/26 16:37, Matthew Wilcox wrote:
> 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).
Alright, but isn't it still the case that if you don't need any of what
struct page provides today or will do in the future, it's better if you just
use kmalloc()? I thought you said so yourself?
https://lore.kernel.org/all/aPQxN7-FeFB6vTuv@casper.infradead.org/
So what exactly would your rationale for "Most of them shouldn't be using
get_free_pages() at all, they should be using kmalloc()." be?
> 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.
next prev parent reply other threads:[~2026-05-26 20:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 8:15 [PATCH] block: partitions: replace __get_free_page() with kmalloc() Mike Rapoport (Microsoft)
2026-05-25 6:08 ` Christoph Hellwig
2026-05-25 6:52 ` Mike Rapoport
2026-05-25 7:16 ` Christoph Hellwig
2026-05-25 9:35 ` Mike Rapoport
2026-05-26 6:27 ` Christoph Hellwig
2026-05-26 12:07 ` Vlastimil Babka
2026-05-26 14:37 ` Matthew Wilcox
2026-05-26 20:57 ` Vlastimil Babka [this message]
2026-05-27 10:04 ` Hannes Reinecke
2026-05-27 13:11 ` Christoph Hellwig
2026-05-27 13:16 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8b780901-8184-4908-8bda-56fac42fe6b3@suse.com \
--to=vbabka@suse.com \
--cc=axboe@kernel.dk \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rppt@kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox