From: Harry Yoo <harry@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@kernel.org>,
Johannes Weiner <hannes@cmpxchg.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <brendan.jackman@linux.dev>,
Zi Yan <ziy@nvidia.com>,
Mel Gorman <mgorman@techsingularity.net>,
linux-mm@kvack.org, kernel-team@meta.com
Subject: Re: [PATCH 0/3] mm/page_alloc: drop the pcp lock before re-enabling IRQs
Date: Tue, 1 Dec 2026 23:53:45 +0000 [thread overview]
Message-ID: <aw9aooZ8D0per2QJ@thinkstation> (raw)
In-Reply-To: <20261201213125.294531-5-joshua.hahnjy@gmail.com>
On Tue, Dec 01, 2026 at 02:05:57PM -0800, Joshua Hahn wrote:
> > > The PCP lock is already complicated and now we're trying to add more
> > > complexity only to avoid disabling and enabling IRQ around the PCP
> > > lock in the common path.
> > >
> > > We should probably revisit the tradeoff made in [1] instead of adding
> > > more complexity, what do you think?
> >
> > Yeah, I think this is very reasonable :p It does seem like a lot to
> > remember about when the IRQ is enabled / disabled and who needs to
> > remember what... I also did not really like the fact that the locking
> > and IRQ toggling wouldn't be FILO if we switched the order of the
> > pcp unlock and IRQ enabling.
> >
> > Anyways, let me do some benchmarking to revisit the cost and the
> > tradeoffs. It would essentially be a revert of Mel's commit but I think
> > there's been a lot of changes on top of it over the years, it might
> > be a bit more plumbing than a simple revert.
>
> Hey Harry, so I did some quick prototyping with AI (diff at the end).
We don't need pcpu_task_pin()/unpin() if we disable IRQs and so the
regression might be overestimated as we disable migration AND IRQs.
We don't need _nopin() variant either.
> So first, disabling IRQs for pcp locks resolves the issue I was seeing
> of pcp lock attempts falling back to the zone lock. From userspace
> this would show up as long softirqs. I re-ran the same benchmark I used
> for the cover letter:
>
> "series" is this 3-part series, "revert" is the diff at the end.
>
> +-------------------+--------+--------+--------+
> | | mm-new | series | revert |
> +-------------------+--------+--------+--------+
> | pcp fallbacks | 136839 | 214 | 0 |
> | callback avg (ms) | 14.6 | 0.6 | 0.6 |
> | softirqs > 65ms | 1059 | 31 | 37 |
> +-------------------+--------+--------+--------+
>
> I guess this is to be expected though.
>
> The next benchmark is about the fast-path cost, which is what Mel's
> commit originally set out to save. I ran David's benchmark with
> one alloc_pages() and __free_pages() on a single CPU. The results are
> median nanoseconds over 30 runs:
>
> +---------+--------+--------+--------+
> | | mm-new | series | revert |
> +---------+--------+--------+--------+
> | order-0 | 80 | 81 | 84 |
> | order-1 | 80 | 80 | 88 |
> | order-3 | 86 | 86 | 95 |
> +---------+--------+--------+--------+
>
> So yeah, there is indeed some regression based on my microbenchmark,
> somewhere between 5% to 10%. This should be the worst-case scenario,
> though. I also ran will-it-scale, this one measures faults per second
> so higher is better:
>
> +-------------+--------+--------+--------+
> | | mm-new | series | revert |
> +-------------+--------+--------+--------+
> | page_fault1 | 1.081M | 1.080M | 1.051M |
> | page_fault2 | 0.756M | 0.760M | 0.752M |
> +-------------+--------+--------+--------+
>
> And here it seems like the regression is a bit smaller (< 3%). Also note
> that between 16 to 128 tasks there wasn't much of a measurable
> difference.
Could you please share statistics for each number of processes next
time you measure it?
--
Cheers,
Harry / Hyeonggon
prev parent reply other threads:[~2026-12-01 23:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 21:27 [PATCH 0/3] mm/page_alloc: drop the pcp lock before re-enabling IRQs Joshua Hahn
2026-11-25 21:27 ` [PATCH 1/3] mm/page_alloc: drop the pcp lock before enabling IRQs after a drain Joshua Hahn
2026-11-26 21:27 ` sashiko-bot
2026-11-25 21:27 ` [PATCH 2/3] mm/page_alloc: drop the pcp lock before enabling IRQs after a refill Joshua Hahn
2026-11-25 21:27 ` [PATCH 3/3] mm/page_alloc: disable IRQs around the remaining pcp drains Joshua Hahn
2026-12-01 1:40 ` [PATCH 0/3] mm/page_alloc: drop the pcp lock before re-enabling IRQs Harry Yoo
2026-12-01 16:24 ` Joshua Hahn
2026-12-01 16:56 ` Harry Yoo
2026-12-01 22:05 ` Joshua Hahn
2026-12-01 23:53 ` Harry Yoo [this message]
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=aw9aooZ8D0per2QJ@thinkstation \
--to=harry@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brendan.jackman@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=kernel-team@meta.com \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--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