Re: [PATCH v1] mm/slub: Genericize x86-specific cmpxchg16b comment
From: Hao Li
Date: Tue Nov 03 2026 - 04:47:05 EST
On Mon, Nov 02, 2026 at 04:27:30PM +0800, Tiezhu Yang wrote:
> The kmalloc_nolock() infrastructure relies on slab caches with double-word
> atomic cmpxchg capabilities (__CMPXCHG_DOUBLE). The current inline comment
> in __kmalloc_nolock_noprof() uses 'cmpxchg16b' as the prerequisite hardware
> capability.
>
> However, "cmpxchg16b" is an x86-specific instruction mnemonic (CX16). On
> modern architectures supported by the Linux kernel, this 128-bit atomic
> primitive is satisfied by different hardware implementations:
> - arm64: satisfies it via LSE atomics ('casp' instruction)
> - s390: satisfies it via native 'cdsg' instruction
> - riscv: satisfies it via ZACAS extension ('amocas.q' instruction)
> - loongarch: satisfies it via SCQ extension (using an 'll.d'/'sc.q' loop)
>
> Update the comment to refer to "128-bit atomic cmpxchg" to accurately
> describe the cross-platform hardware invariant needed by the lockless
> allocator, and to avoid misleading developers of non-x86 archs.
Personally, I feel the commit message is a bit lengthy for a simple
comment-only patch. It might be better to keep it concise and just directly
state the purpose of the change.
--
Thanks,
Hao