Re: [PATCH] x86/mm/pat: take cpa_lock around large-page collapse
From: Mike Rapoport
Date: Sat Jul 11 2026 - 04:56:58 EST
On Fri, Jul 10, 2026 at 10:13:21AM -0700, Dave Hansen wrote:
> On 6/26/26 09:32, Denis V. Lunev wrote:
> > + /*
> > + * debug_pagealloc bypasses cpa_lock, so __change_page_attr() walks
> > + * unserialized and freeing collapsed PTE-tables could race it; skip
> > + * the optional merge there.
> > + */
> > + if (debug_pagealloc_enabled())
> > + return;
>
> Wow, that debug_pagealloc hack is ancient and came with the original
> introduction of cpa_lock:
>
> > commit ad5ca55f6bdb47c957b681c7358bb3719ba4ee82
> > Author: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
> > Date: Tue Sep 23 14:00:42 2008 -0700
> >
> > x86, cpa: srlz cpa(), global flush tlb after splitting big page and before doing cpa
>
> My only question is *why*!?!? Why add extra locking complexity and rules
> to optimize debug_pagealloc, which is already horrendously slow.
My guess would be that the logic was to lock only when a split is possible
and since debug_pagealloc does not split anything, skip the lock.
> I kinda think we should just _remove_ the locking which is conditional
> on debug_pagealloc_enabled().
I agree.
--
Sincerely yours,
Mike.