Re: [PATCH] x86/mm/pat: don't gate cpa_lock on debug_pagealloc_enabled()

From: Mike Rapoport

Date: Tue Jul 28 2026 - 11:52:05 EST


On Tue, Jul 28, 2026 at 06:53:56AM -0700, Breno Leitao wrote:
> On Wed, Jul 15, 2026 at 05:45:19PM +0300, Mike Rapoport wrote:
> > @@ -1235,11 +1234,9 @@ static int split_large_page(struct cpa_data *cpa, pte_t *kpte,
> > {
> > struct ptdesc *ptdesc;
> >
> > - if (!debug_pagealloc_enabled())
> > - spin_unlock(&cpa_lock);
> > + spin_unlock(&cpa_lock);
> > ptdesc = pagetable_alloc(GFP_KERNEL, 0);
> > - if (!debug_pagealloc_enabled())
> > - spin_lock(&cpa_lock);
> > + spin_lock(&cpa_lock);
>
> A DEBUG_PAGEALLOC + KASAN kernel from linux-next-20260727 fails to finish
> booting on a large VM (many CPUs + large memory). Boot stalls in early
> userspace with a non-responsive CSD lock; it never reaches a login.
>
> I bisected it to this patch, which is the following on linux-next:
>
> 5fce67641a3e ("x86/mm/pat: Don't gate cpa_lock on debug_pagealloc_enabled()")
>
> Reverting it (restoring the !debug_pagealloc_enabled() gating around
> cpa_lock) makes the same kernel boot reliably.
>
> Symptom
> -------
>
> Boot hangs during udev coldplug (concurrent module loading, i.e. concurrent
> set_memory()). With csdlock_debug=1 the console shows:
>
> smp: csd: Detected non-responsive CSD lock (#1) on CPU#55, waiting
> 5000000019 ns for CPU#57 do_flush_tlb_all+0x0/0x30(0x0).
> smp: csd: CSD lock (#1) unresponsive.
> Sending NMI from CPU 55 to CPUs 57:
> NMI backtrace for cpu 57
> CPU: 57 UID: 0 PID: 860 Comm: (udev-worker) Tainted: G E \
> 7.2.0-rc5-next-20260727 #1 PREEMPT(full)
> RIP: 0010:queued_spin_lock_slowpath+0xae/0xd30
> Call Trace:
> <TASK>
> do_raw_spin_lock+0x268/0x2f0
> __change_page_attr_set_clr+0x32d/0x21f0
> ...
>
> CPU#55 is stuck in flush_tlb_all() waiting for CPU#57 to answer the IPI;
> CPU#57 is spinning on cpa_lock (RBX resolves to cpa_lock) inside
> __change_page_attr_set_clr(). The clocksource watchdog also reports
> remote CPUs timing out on the same IPIs just before this.
>
> Is this a known issue?

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

> --breno

--
Sincerely yours,
Mike.