Re: [PATCH v1 1/2] LoongArch: BPF: Make arena support depend on SCQ extension

From: George Guo

Date: Wed Nov 04 2026 - 05:22:06 EST


Hi Tiezhu,

On 2026/11/2 15:28, Tiezhu Yang wrote:
> This is because the arena range tree uses kmalloc_nolock(), which requires
> 128-bit atomic cmpxchg support, provided by SCQ extension on LoongArch.

There is an existing SLUB debug fallback worth checking before making
arena support depend on SCQ.

In __kmalloc_nolock_noprof(), the rejection condition is:

if (!(s->flags & __CMPXCHG_DOUBLE) && !kmem_cache_debug(s))
return NULL;

Debug caches do not require cmpxchg128 for this path. They use
kmem_cache_node->list_lock with spin_trylock_irqsave() instead.
With CONFIG_SLUB_DEBUG=y, booting with slab_debug enables this path;
CONFIG_SLUB_DEBUG_ON=y enables debugging by default as well.

The proposed bpf_jit_supports_arena() check would reject arena maps on
CPUs without SCQ, even when the SLUB debug fallback is available.
This would prevent us from running arena tests on those machines
with slab_debug enabled.

Could you rerun jit_insns/cast_to_user on the 3A5000 with slab_debug
enabled, before and after this patch? The claim that kmalloc_nolock()
requires 128-bit cmpxchg should account for debug caches, and it would
be useful to preserve that fallback when addressing the error reporting.

Thanks,
George