From: Johannes Weiner <hannes@cmpxchg.org>
To: Vlastimil Babka <vbabka@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>, Zi Yan <ziy@nvidia.com>,
Mel Gorman <mgorman@techsingularity.net>,
Matthew Wilcox <willy@infradead.org>,
"David Hildenbrand (Arm)" <david@kernel.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH 1/3] mm/page_alloc: effectively disable pcp with CONFIG_SMP=n
Date: Mon, 2 Mar 2026 12:12:48 -0500 [thread overview]
Message-ID: <aaXFEDw2jrBGZNm7@cmpxchg.org> (raw)
In-Reply-To: <20260227-b4-pcp-locking-cleanup-v1-1-f7e22e603447@kernel.org>
On Fri, Feb 27, 2026 at 06:07:58PM +0100, Vlastimil Babka wrote:
> The page allocator has been using a locking scheme for its percpu page
> caches (pcp) based on spin_trylock() with no _irqsave() part. The trick
> is that if we interrupt the locked section, we fail the trylock and just
> fallback to the slowpath taking the zone lock. That's more expensive,
> but rare, so we don't need to pay the irqsave/restore cost all the time
> in the fastpaths.
>
> It's similar to but not exactly local_trylock_t (which is also newer anyway)
> because in some cases we do lock the pcp of a non-local cpu to drain it, in
> a way that's cheaper than using IPI or queue_work_on().
>
> The complication of this scheme has been UP non-debug spinlock
> implementation which assumes spin_trylock() can't fail on UP and has no
> state to track whether it's locked. It just doesn't anticipate this
> usage scenario. So to work around that we disable IRQs only on UP,
> complicating the implementation. Also recently we found years old bug in
> where we didn't disable IRQs in related paths - see 038a102535eb
> ("mm/page_alloc: prevent pcp corruption with SMP=n").
>
> We can avoid this UP complication by realizing that we do not need the
> pcp caching for scalability on UP in the first place. Removing it
> completely with #ifdefs is not worth the trouble either. Just make
> pcp_spin_trylock() return NULL unconditionally on CONFIG_SMP=n. This
> makes the slowpaths unconditional, and we can remove the IRQ
> save/restore handling in pcp_spin_trylock()/unlock() completely.
>
> Suggested-by: David Hildenbrand (Arm) <david@kernel.org>
> Signed-off-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
next prev parent reply other threads:[~2026-03-02 17:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 17:07 [PATCH 0/3] mm/page_alloc: pcp locking cleanup Vlastimil Babka
2026-02-27 17:07 ` [PATCH 1/3] mm/page_alloc: effectively disable pcp with CONFIG_SMP=n Vlastimil Babka
2026-03-02 17:12 ` Johannes Weiner [this message]
2026-03-03 16:09 ` David Hildenbrand (Arm)
2026-03-03 16:21 ` Vlastimil Babka
2026-02-27 17:07 ` [PATCH 2/3] mm/page_alloc: remove IRQ saving/restoring from pcp locking Vlastimil Babka
2026-03-02 17:17 ` Johannes Weiner
2026-02-27 17:08 ` [PATCH 3/3] mm/page_alloc: remove pcpu_spin_* wrappers Vlastimil Babka
2026-03-02 17:18 ` Johannes Weiner
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=aaXFEDw2jrBGZNm7@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=david@kernel.org \
--cc=jackmanb@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=willy@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.