Re: [PATCH 3/3] x86/mm: Fix and document DEBUG_PAGEALLOC

From: Mike Rapoport

Date: Thu Jul 30 2026 - 07:34:14 EST


On Thu, Jul 30, 2026 at 12:43:33PM +0200, Peter Zijlstra wrote:
> On Wed, Jul 29, 2026 at 10:07:27PM +0300, Mike Rapoport wrote:
>
> > > > I like my version with your comments added there more as it localizes the
> > > > DEBUG_PAGEALLOC exception in the lock wrappers.
> > >
> > > So I don't like removing cpa_lock entirely; it is still serializing cpa
> >
> > I meant static inline cpa_lock(), not removing it entirely.
> > With your comment why DEBUG_PAGEALLOC is special.
>
> That is, I despise the whole:
>
> if (!debug_pagealloc_enabled())
> spin_lock(&cpa_lock);
>
> with a passion. It blanked kills cpa_lock as whole and changes the rules
> for everyone when debug_pagealloc is on.
>
> cpa_lock ensures that concurrent cpa() calls on an overlapping region
> have a well defined outcome. By removing it entirely you can get random
> state.
>
> In practise this isn't likely to matter, but relaxing this for a debug
> option is insane. Debug stuff should tighten rules, not relax them.

In practice it's the same, either the thread that won the race for lock
updates the pte or just the first one to get to actual set_pte and it's
pretty random for overlapping regions anyway.

But I can see your point.

Anyway, we need Lorenzo's fixes from the set I sent [1] to protect against
other races and they conflict with your patches :(

If you are planning to send v2 maybe you can take them on top as well?

[1] https://lore.kernel.org/all/20260728-cpa-fixes-v1-0-2ed2352300b3@xxxxxxxxxx

--
Sincerely yours,
Mike.