From: Uladzislau Rezki <urezki@gmail.com>
To: Matthew Wilcox <willy@infradead.org>,
"Vishal Moola (Oracle)" <vishal.moola@gmail.com>
Cc: "Vishal Moola (Oracle)" <vishal.moola@gmail.com>,
Uladzislau Rezki <urezki@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC PATCH] mm/vmalloc: request large order pages from buddy allocator
Date: Wed, 15 Oct 2025 15:42:50 +0200 [thread overview]
Message-ID: <aO-k2hBimow9oYuR@milan> (raw)
In-Reply-To: <aO-Wxj7al7I-IadV@casper.infradead.org>
On Wed, Oct 15, 2025 at 01:42:46PM +0100, Matthew Wilcox wrote:
> On Wed, Oct 15, 2025 at 03:44:22AM -0700, Vishal Moola (Oracle) wrote:
> > On Wed, Oct 15, 2025 at 10:23:19AM +0200, Uladzislau Rezki wrote:
> > > > int i;
> > > > + gfp_t large_gfp = (gfp & ~__GFP_DIRECT_RECLAIM) | __GFP_NOWARN;
> > > > + unsigned int large_order = ilog2(nr_pages - nr_allocated);
> > > >
> > > If large_order is > MAX_ORDER - 1 then there is no need even try
> > > larger_order attempt.
>
> Oh, I meant to mention that too. Yes, this should be min(MAX_ORDER, ilog2()).
>
> > > Maybe it is worth to drop/warn if __GFP_COMP is set also?
> >
> > split_page() has a BUG_ON(PageCompound) within, so we don't need one out
> > here for now.
>
> I don't think people actually call vmalloc() with __GFP_COMP set, but
> clearing it would do no harm here.
>
Agree. We do not want BUG_ON() in split_page(). I think it is better to
control this even though nobody invokes vmalloc() with __GFP_COMP.
> > > The concern is then if it is a waste of high-order pages. Because we can
> > > easily go with a single page allocator. Whereas someone in a system can not.
> >
> > I feel like if we have high order pages available we'd rather allocate
> > those. Since the buddy allocator just coalesces the pages when they're
> > freed again, as soon as these allocations free up we are much more
> > likely to have large order pages ready to go again.
>
> My PoV is different from either of you -- that we actually want
> to allocate the high-order pages when we can because it reduces
> fragmentation. If we allocate five separate pages to satisfy a 20kB
> allocation, those may come from five different 2MB pages (since they're
> probably coming from the pcp lists which after a sufficiently long period
> of running will be a jumble). Whereas if we allocate an order-2 page
> and an order-0 page, those can come from at most two 2MB pages.
>
> I understand the "allocating order-0 pages helps by using up the remnants
> of previous allocations" argument. But I think on the whole we need to
> be doing larger allocations where possible, not smaller ones.
>
OK, i see. Then we can start from highest "fit" order as starting point
and switch to lower ones if failing. Fallback to bulk or single page
allocator if it is still not enough pages.
Thank you!
--
Uladzislau Rezki
next prev parent reply other threads:[~2025-10-15 13:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-14 18:27 Vishal Moola (Oracle)
2025-10-15 3:56 ` Matthew Wilcox
2025-10-15 9:28 ` Vishal Moola (Oracle)
2025-10-16 16:12 ` Uladzislau Rezki
2025-10-16 17:42 ` Vishal Moola (Oracle)
2025-10-16 19:02 ` Vishal Moola (Oracle)
2025-10-17 16:15 ` Uladzislau Rezki
2025-10-17 17:19 ` Uladzislau Rezki
2025-10-20 18:23 ` Vishal Moola (Oracle)
2025-10-15 8:23 ` Uladzislau Rezki
2025-10-15 10:44 ` Vishal Moola (Oracle)
2025-10-15 12:42 ` Matthew Wilcox
2025-10-15 13:42 ` Uladzislau Rezki [this message]
2025-10-16 6:57 ` Christoph Hellwig
2025-10-16 11:53 ` Uladzislau Rezki
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=aO-k2hBimow9oYuR@milan \
--to=urezki@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vishal.moola@gmail.com \
--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