Re: [PATCH 1/3] mm/page_alloc: effectively disable pcp with CONFIG_SMP=n

From: David Hildenbrand (Arm)

Date: Tue Mar 03 2026 - 11:10:01 EST


> - * With the UP spinlock implementation, when we spin_lock(&pcp->lock) (for i.e.
> - * a potentially remote cpu drain) and get interrupted by an operation that
> - * attempts pcp_spin_trylock(), we can't rely on the trylock failure due to UP
> - * spinlock assumptions making the trylock a no-op. So we have to turn that
> - * spin_lock() to a spin_lock_irqsave(). This works because on UP there are no
> - * remote cpu's so we can only be locking the only existing local one.
> + * On CONFIG_SMP=n the UP implementation of spin_trylock() never fails and thus
> + * is not compatible with our locking scheme. However we do not need pcp for
> + * scalability in the first place, so just make all the trylocks fail and take
> + * the slow path unconditionally.
> */
> +#else
> +#define pcp_spin_trylock(ptr) \
> + NULL
> +
> +#define pcp_spin_unlock(ptr) \
> + BUG_ON(1)

Did you try turning this into a BUILD_BUG() ?
I'd assume that the compiler would optimize-out all dead code and
consequently not trigger the BUILD_BUG.

if (pcp_spin_trylock()) {
/* dead code */
pcp_spin_unlock()
}

IIUC, the trylock+unlock is not really split over multiple functions.

--
Cheers,

David