Skip to content

Commit 6e30a7c

Browse files
ubizjakIngo Molnar
authored andcommitted
locking/atomic/x86: Introduce the read64_nonatomic macro to x86_32 with cx8
As described in commit: e73c4e3 ("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 the read64_nonatomic assembly macro to load the value from a atomic_t location in a faster non-atomic way and use it in atomic64_cx8_32.S. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/20240605181424.3228-1-ubizjak@gmail.com
1 parent 5183594 commit 6e30a7c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/x86/lib/atomic64_cx8_32.S

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
cmpxchg8b (\reg)
1717
.endm
1818

19+
.macro read64_nonatomic reg
20+
movl (\reg), %eax
21+
movl 4(\reg), %edx
22+
.endm
23+
1924
SYM_FUNC_START(atomic64_read_cx8)
2025
read64 %ecx
2126
RET
@@ -51,7 +56,7 @@ SYM_FUNC_START(atomic64_\func\()_return_cx8)
5156
movl %edx, %edi
5257
movl %ecx, %ebp
5358

54-
read64 %ecx
59+
read64_nonatomic %ecx
5560
1:
5661
movl %eax, %ebx
5762
movl %edx, %ecx
@@ -79,7 +84,7 @@ addsub_return sub sub sbb
7984
SYM_FUNC_START(atomic64_\func\()_return_cx8)
8085
pushl %ebx
8186

82-
read64 %esi
87+
read64_nonatomic %esi
8388
1:
8489
movl %eax, %ebx
8590
movl %edx, %ecx

0 commit comments

Comments
 (0)