locking/atomic/x86: Introduce read64_nonatomic macro to x86_32 with cx8
Subsystems (2)
PATCH 1/2 locking/atomic/x86: Introduce read64_nonatomic macro to x86_32 with cx8
As described in:
commit e73c4e34a0e9 ("locking/atomic/x86: Introduce arch_atomic64_read_nonatomic() to x86_32")
the value preload before the cmpxchg loop does not need to be atomic. Introduce read64_nonatomic macro to load the value from atomic_t location in a faster non-atomic way and use it in atomic64_cx8_32.S.
Signed-off-by Uros Bizjak <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
--- arch/x86/lib/atomic64_cx8_32.S | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/x86/lib/atomic64_cx8_32.S +7 -2
@@ -16,6 +16,11 @@ cmpxchg8b (\reg) .endm +.macro read64_nonatomic reg + movl (\reg), %eax + movl 4(\reg), %edx +.endm + SYM_FUNC_START(atomic64_read_cx8) read64 %ecx RET
@@ -51,7 +56,7 @@ SYM_FUNC_START(atomic64_\func\()_return_cx8) movl %edx, %edi movl %ecx, %ebp - read64 %ecx + read64_nonatomic %ecx 1: movl %eax, %ebx movl %edx, %ecx
@@ -79,7 +84,7 @@ addsub_return sub sub sbb SYM_FUNC_START(atomic64_\func\()_return_cx8) pushl %ebx - read64 %esi + read64_nonatomic %esi 1: movl %eax, %ebx movl %edx, %ecx
Signature · 1 line
2.42.0
PATCH 2/2 locking/atomic/x86: Redeclare x86_32 arch_atomic64_{add,sub}() as void
Correct the return type of x86_32 arch_atomic64_add() and arch_atomic64_sub() functions to void and remove redundant return.
Signed-off-by Uros Bizjak <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dave Hansen <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
--- arch/x86/include/asm/atomic64_32.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/x86/include/asm/atomic64_32.h +2 -4
@@ -163,20 +163,18 @@ static __always_inline s64 arch_atomic64_dec_return(atomic64_t *v) }#define arch_atomic64_dec_return arch_atomic64_dec_return -static __always_inline s64 arch_atomic64_add(s64 i, atomic64_t *v) +static __always_inline void arch_atomic64_add(s64 i, atomic64_t *v) {__alternative_atomic64 (add, add_return,ASM_OUTPUT2 ("+A" (i),"+c" (v)),ASM_NO_INPUT_CLOBBER ("memory" )); -return i; } -static __always_inline s64 arch_atomic64_sub(s64 i, atomic64_t *v) +static __always_inline void arch_atomic64_sub(s64 i, atomic64_t *v) {__alternative_atomic64 (sub, sub_return,ASM_OUTPUT2 ("+A" (i),"+c" (v)),ASM_NO_INPUT_CLOBBER ("memory" )); -return i; } static __always_inline void arch_atomic64_inc(atomic64_t *v)
Signature · 1 line
2.42.0