Re: [PATCH RFC 01/18] x86/mm/pat: Don't gate cpa_lock on debug_pagealloc_enabled()
From: Lorenzo Stoakes (ARM)
Date: Wed Jul 22 2026 - 05:07:16 EST
On Tue, Jul 21, 2026 at 09:30:26PM +0300, Mike Rapoport wrote:
> On Tue, Jul 21, 2026 at 06:16:33PM +0100, Lorenzo Stoakes (ARM) wrote:
> > On Tue, Jul 21, 2026 at 07:23:24PM +0300, Mike Rapoport (Microsoft) wrote:
> > > The splitting and merging of kernel page table mappings between small and
> > > large is protected by cpa_lock. The merging is relatively new but the
> > > splitting is ancient.
> > >
> > > The splitting has a locking optimization: since DEBUG_PAGEALLOC forces all
> > > mappings to 4k, there are no large pages to split. So the code that *might*
> > > cause a split can just skip the locking (and a few other things).
> > >
> > > This is entertaining, but it adds complexity and makes for weird locking
> > > rules. Plus it's all for a debugging feature which makes the kernel super
> > > slow in the first place. Optimizing something which is already super slow
> > > and not used in production is not the best way to spend our complexity
> > > budget.
> > >
> > > Stop gating cpa_lock on debug_pagealloc_enabled() to simplify the code
> > > and the locking rules.
> > >
> > > [ dhansen: flesh out changelog ]
> > >
> > > Suggested-by: Dave Hansen <dave.hansen@xxxxxxxxx>
> > > Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> > > Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> > > Link: https://patch.msgid.link/20260715144519.934289-1-rppt@xxxxxxxxxx
> > > Link: https://lore.kernel.org/all/aab44f08-89f8-47fe-bee4-0ab6b25968c6@xxxxxxxxx/
> >
> > Hmm this patch is already taken separately though? ([0]) (obv. commented there
> > already with review feedback).
> >
> > Intended to be with this series as some kind of background or? Probably better
> > to separate out given it's a live patch
>
> From the cover letter:
>
> Patch 1 is already applied to the tip tree and I posted patch 2
> separately [4], but I included them both here for the completeness.
Well that'll teach me for skipping the cover letter ;) Fair enough!
>
> > Thanks, Lorenzo
>
> --
> Sincerely yours,
> Mike.
Cheers, Lorenzo