FAILED: patch "[PATCH] x86/locking: Use sfence for wmb() if SSE is available" failed to apply to 6.12-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x d824ed1307680dd482f607b0e707c575f70668c4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090322-unsaid-demote-cc78@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d824ed1307680dd482f607b0e707c575f70668c4 Mon Sep 17 00:00:00 2001
From: Yao Zi <[email protected]>
Date: Sat, 1 Aug 2026 18:29:53 +0000
Subject: [PATCH] x86/locking: Use sfence for wmb() if SSE is available
When adding cc clobber to wmb()'s definition, the alternative() condition to use sfence was incorrectly raised from X86_FEATURE_XMM to X86_FEATURE_XMM2.
Restore the correct constraint for potential better performance on machines without SSE2.
arch/x86/include/asm/barrier.h +1 -1
@@ -17,7 +17,7 @@#define rmb () asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "lfence", \ X86_FEATURE_XMM2) ::: "memory", "cc")#define wmb () asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "sfence", \ - X86_FEATURE_XMM2) ::: "memory", "cc") + X86_FEATURE_XMM) ::: "memory", "cc")#else #define __mb () asm volatile("mfence":::"memory")#define __rmb () asm volatile("lfence":::"memory")
Sasha Levin
maintainerPATCH 1/2 x86/locking: Remove semicolon from "lock" prefix
From: Uros Bizjak <[email protected]>
[ Upstream commit 023f3290b02552ea006c1a2013e373750d2cbff6 ]
Minimum version of binutils required to compile the kernel is 2.25. This version correctly handles the "lock" prefix, so it is possible to remove the semicolon, which was used to support ancient versions of GNU as.
Due to the semicolon, the compiler considers "lock; insn" as two separate instructions. Removing the semicolon makes asm length calculations more accurate, consequently making scheduling and inlining decisions of the compiler more accurate.
Removing the semicolon also enables assembler checks involving lock prefix. Trying to assemble e.g. "lock andl %eax, %ebx" results in:
Error: expecting lockable instruction after `lock'
Stable-dep-of: d824ed130768 ("x86/locking: Use sfence for wmb() if SSE is available")
--- arch/x86/include/asm/alternative.h | 2 +- arch/x86/include/asm/barrier.h | 8 ++++---- arch/x86/include/asm/cmpxchg.h | 4 ++-- arch/x86/include/asm/cmpxchg_32.h | 4 ++-- arch/x86/include/asm/edac.h | 2 +- arch/x86/include/asm/sync_bitops.h | 12 ++++++------ 6 files changed, 16 insertions(+), 16 deletions(-)
arch/x86/include/asm/alternative.h +1 -1
@@ -48,7 +48,7 @@".popsection\n" \ "671:" -#define LOCK_PREFIX LOCK_PREFIX_HERE "\n\tlock; " +#define LOCK_PREFIX LOCK_PREFIX_HERE "\n\tlock "#else /* ! CONFIG_SMP */ #define LOCK_PREFIX_HERE ""
arch/x86/include/asm/barrier.h +4 -4
@@ -12,11 +12,11 @@*/ #ifdef CONFIG_X86_32 -#define mb () asm volatile(ALTERNATIVE("lock; addl $0,-4(%%esp)", "mfence", \ +#define mb () asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "mfence", \ X86_FEATURE_XMM2) ::: "memory", "cc") -#define rmb () asm volatile(ALTERNATIVE("lock; addl $0,-4(%%esp)", "lfence", \ +#define rmb () asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "lfence", \ X86_FEATURE_XMM2) ::: "memory", "cc") -#define wmb () asm volatile(ALTERNATIVE("lock; addl $0,-4(%%esp)", "sfence", \ +#define wmb () asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "sfence", \ X86_FEATURE_XMM2) ::: "memory", "cc")#else #define __mb () asm volatile("mfence":::"memory")
@@ -50,7 +50,7 @@#define __dma_rmb () barrier()#define __dma_wmb () barrier() -#define __smp_mb () asm volatile("lock; addl $0,-4(%%" _ASM_SP ")" ::: "memory", "cc") +#define __smp_mb () asm volatile("lock addl $0,-4(%%" _ASM_SP ")" ::: "memory", "cc")#define __smp_rmb () dma_rmb()#define __smp_wmb () barrier()
arch/x86/include/asm/cmpxchg.h +2 -2
@@ -134,7 +134,7 @@ extern void __add_wrong_size(void) __raw_cmpxchg((ptr), (old), (new), (size), LOCK_PREFIX)#define __sync_cmpxchg (ptr, old, new, size) \ - __raw_cmpxchg((ptr), (old), (new), (size), "lock; ") + __raw_cmpxchg((ptr), (old), (new), (size), "lock ")#define __cmpxchg_local (ptr, old, new, size) \ __raw_cmpxchg((ptr), (old), (new), (size), "")
@@ -222,7 +222,7 @@ extern void __add_wrong_size(void) __raw_try_cmpxchg((ptr), (pold), (new), (size), LOCK_PREFIX)#define __sync_try_cmpxchg (ptr, pold, new, size) \ - __raw_try_cmpxchg((ptr), (pold), (new), (size), "lock; ") + __raw_try_cmpxchg((ptr), (pold), (new), (size), "lock ")#define __try_cmpxchg_local (ptr, pold, new, size) \ __raw_try_cmpxchg((ptr), (pold), (new), (size), "")
arch/x86/include/asm/cmpxchg_32.h +2 -2
@@ -103,7 +103,7 @@ static __always_inline bool __try_cmpxchg64_local(volatile u64 *ptr, u64 *oldp, static __always_inline u64 arch_cmpxchg64(volatile u64 *ptr, u64 old, u64 new) { -return __arch_cmpxchg64_emu (ptr, old, new,LOCK_PREFIX_HERE ,"lock; " ); +return __arch_cmpxchg64_emu (ptr, old, new,LOCK_PREFIX_HERE ,"lock " ); }#define arch_cmpxchg64 arch_cmpxchg64
@@ -136,7 +136,7 @@ static __always_inline u64 arch_cmpxchg64_local(volatile u64 *ptr, u64 old, u64 static __always_inline bool arch_try_cmpxchg64(volatile u64 *ptr, u64 *oldp, u64 new) { -return __arch_try_cmpxchg64_emu (ptr, oldp, new,LOCK_PREFIX_HERE ,"lock; " ); +return __arch_try_cmpxchg64_emu (ptr, oldp, new,LOCK_PREFIX_HERE ,"lock " ); }#define arch_try_cmpxchg64 arch_try_cmpxchg64
arch/x86/include/asm/edac.h +1 -1
@@ -13,7 +13,7 @@ static inline void edac_atomic_scrub(void *va, u32 size)* are interrupt, DMA and SMP safe. */ for (i =0 ; i < size /4 ; i++, virt_addr++) - asm volatile("lock; addl $0, %0"::"m" (*virt_addr)); + asm volatile("lock addl $0, %0"::"m" (*virt_addr)); }#endif /* _ASM_X86_EDAC_H */
arch/x86/include/asm/sync_bitops.h +6 -6
@@ -31,7 +31,7 @@*/ static inline void sync_set_bit (long nr,volatile unsigned long *addr) { - asm volatile("lock; " __ASM_SIZE(bts) " %1,%0" + asm volatile("lock " __ASM_SIZE(bts) " %1,%0" : "+m" (ADDR) : "Ir" (nr) : "memory");
@@ -49,7 +49,7 @@ static inline void sync_set_bit(long nr, volatile unsigned long *addr)*/ static inline void sync_clear_bit (long nr,volatile unsigned long *addr) { - asm volatile("lock; " __ASM_SIZE(btr) " %1,%0" + asm volatile("lock " __ASM_SIZE(btr) " %1,%0" : "+m" (ADDR) : "Ir" (nr) : "memory");
@@ -66,7 +66,7 @@ static inline void sync_clear_bit(long nr, volatile unsigned long *addr)*/ static inline void sync_change_bit (long nr,volatile unsigned long *addr) { - asm volatile("lock; " __ASM_SIZE(btc) " %1,%0" + asm volatile("lock " __ASM_SIZE(btc) " %1,%0" : "+m" (ADDR) : "Ir" (nr) : "memory");
@@ -82,7 +82,7 @@ static inline void sync_change_bit(long nr, volatile unsigned long *addr)*/ static inline bool sync_test_and_set_bit (long nr,volatile unsigned long *addr) { -return GEN_BINARY_RMWcc ("lock; " __ASM_SIZE(bts), *addr, c,"Ir" , nr); +return GEN_BINARY_RMWcc ("lock " __ASM_SIZE(bts), *addr, c,"Ir" , nr); }/**
@@ -95,7 +95,7 @@ static inline bool sync_test_and_set_bit(long nr, volatile unsigned long *addr)*/ static inline int sync_test_and_clear_bit (long nr,volatile unsigned long *addr) { -return GEN_BINARY_RMWcc ("lock; " __ASM_SIZE(btr), *addr, c,"Ir" , nr); +return GEN_BINARY_RMWcc ("lock " __ASM_SIZE(btr), *addr, c,"Ir" , nr); }/**
@@ -108,7 +108,7 @@ static inline int sync_test_and_clear_bit(long nr, volatile unsigned long *addr)*/ static inline int sync_test_and_change_bit (long nr,volatile unsigned long *addr) { -return GEN_BINARY_RMWcc ("lock; " __ASM_SIZE(btc), *addr, c,"Ir" , nr); +return GEN_BINARY_RMWcc ("lock " __ASM_SIZE(btc), *addr, c,"Ir" , nr); }#define sync_test_bit (nr, addr) test_bit(nr, addr)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 x86/locking: Use sfence for wmb() if SSE is available
From: Yao Zi <[email protected]>
[ Upstream commit d824ed1307680dd482f607b0e707c575f70668c4 ]
When adding cc clobber to wmb()'s definition, the alternative() condition to use sfence was incorrectly raised from X86_FEATURE_XMM to X86_FEATURE_XMM2.
Restore the correct constraint for potential better performance on machines without SSE2.
--- arch/x86/include/asm/barrier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/barrier.h +1 -1
@@ -17,7 +17,7 @@#define rmb () asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "lfence", \ X86_FEATURE_XMM2) ::: "memory", "cc")#define wmb () asm volatile(ALTERNATIVE("lock addl $0,-4(%%esp)", "sfence", \ - X86_FEATURE_XMM2) ::: "memory", "cc") + X86_FEATURE_XMM) ::: "memory", "cc")#else #define __mb () asm volatile("mfence":::"memory")#define __rmb () asm volatile("lfence":::"memory")
Signature · 1 line
2.53.0