mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: shengminghu512 <shengminghu512@qq.com>
To: "Andrew Morton" <akpm@linux-foundation.org>
Cc: vbabka <vbabka@suse.cz>, surenb <surenb@google.com>,
	mhocko <mhocko@suse.com>, jackmanb <jackmanb@google.com>,
	hannes <hannes@cmpxchg.org>, ziy <ziy@nvidia.com>,
	linux-mm <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"hu.shengming" <hu.shengming@zte.com.cn>,
	"zhang.run" <zhang.run@zte.com.cn>
Subject: Re: [PATCH linux-next] mm/page_alloc: avoid overcounting bulk allocin watermark check
Date: Fri, 30 Jan 2026 08:29:05 +0800	[thread overview]
Message-ID: <tencent_BAE640F74B4B0434E930276D1AD12E67FB08@qq.com> (raw)
In-Reply-To: <20260129141057.b577100c834c726f01a602b9@linux-foundation.org>

> On Thu, 29 Jan 2026 22:38:14 +0800 "shengminghu512" <shengminghu512@qq.com> wrote:
> 
> > From: Shengming Hu <hu.shengming@zte.com.cn>
> > 
> > alloc_pages_bulk_noprof() only fills NULL slots and already tracks how many
> > entries are pre-populated via nr_populated.
> > 
> > The fast watermark check was adding nr_pages unconditionally, which can
> > overestimate the demand. Use (nr_pages - nr_populated) instead, as an 
> > upper bound on the remaining pages this call can still allocate without
> > scanning the whole array.
> 
> Thanks.
> 
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -5130,7 +5130,7 @@ unsigned long alloc_pages_bulk_noprof(gfp_t gfp, int preferred_nid,
> >  
> >   cond_accept_memory(zone, 0, alloc_flags);
> >  retry_this_zone:
> > - mark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK) + nr_pages;
> > + mark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK) + nr_pages - nr_populated;
> >   if (zone_watermark_fast(zone, 0,  mark,
> >   zonelist_zone_idx(ac.preferred_zoneref),
> >   alloc_flags, gfp)) {
> 
> So that little optimization hasn't been working for four years?

Yeah, looks like it’s been conservative for a long time :)

It didn’t break correctness, but it likely made the fast watermark check
less effective by overestimating demand (counting already-populated entries
again), so we’d drop out of `zone_watermark_fast()` earlier and hit the
slow path more often.

--
With Best Regards,
Shengming

  reply	other threads:[~2026-01-30  0:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-29 14:38 [PATCH linux-next] mm/page_alloc: avoid overcounting bulk alloc in " shengminghu512
2026-01-29 22:10 ` Andrew Morton
2026-01-30  0:29   ` shengminghu512 [this message]
2026-02-12 15:57 ` Vlastimil Babka

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=tencent_BAE640F74B4B0434E930276D1AD12E67FB08@qq.com \
    --to=shengminghu512@qq.com \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=hu.shengming@zte.com.cn \
    --cc=jackmanb@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=zhang.run@zte.com.cn \
    --cc=ziy@nvidia.com \
    /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

all inboxes | Powered by JetHome®