Skip to content

Commit a432b7c

Browse files
ubizjakIngo Molnar
authored and
Ingo Molnar
committed
locking/lockref/x86: Enable ARCH_USE_CMPXCHG_LOCKREF for X86_CMPXCHG64
The following commit: bc08b44 ("lockref: implement lockless reference count updates using cmpxchg()") enabled lockless reference count updates using cmpxchg() only for x86_64, and left x86_32 behind due to inability to detect support for cmpxchg8b instruction. Nowadays, we can use CONFIG_X86_CMPXCHG64 for this purpose. Also, by using try_cmpxchg64() instead of cmpxchg64() in the CMPXCHG_LOOP macro, the compiler actually produces sane code, improving the lockref_get_not_zero() main loop from: eb: 8d 48 01 lea 0x1(%eax),%ecx ee: 85 c0 test %eax,%eax f0: 7e 2f jle 121 <lockref_get_not_zero+0x71> f2: 8b 44 24 10 mov 0x10(%esp),%eax f6: 8b 54 24 14 mov 0x14(%esp),%edx fa: 8b 74 24 08 mov 0x8(%esp),%esi fe: f0 0f c7 0e lock cmpxchg8b (%esi) 102: 8b 7c 24 14 mov 0x14(%esp),%edi 106: 89 c1 mov %eax,%ecx 108: 89 c3 mov %eax,%ebx 10a: 8b 74 24 10 mov 0x10(%esp),%esi 10e: 89 d0 mov %edx,%eax 110: 31 fa xor %edi,%edx 112: 31 ce xor %ecx,%esi 114: 09 f2 or %esi,%edx 116: 75 58 jne 170 <lockref_get_not_zero+0xc0> to: 350: 8d 4f 01 lea 0x1(%edi),%ecx 353: 85 ff test %edi,%edi 355: 7e 79 jle 3d0 <lockref_get_not_zero+0xb0> 357: f0 0f c7 0e lock cmpxchg8b (%esi) 35b: 75 53 jne 3b0 <lockref_get_not_zero+0x90> Signed-off-by: Uros Bizjak <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6f23fc4 commit a432b7c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ config X86_64
2828
select ARCH_HAS_GIGANTIC_PAGE
2929
select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
3030
select ARCH_SUPPORTS_PER_VMA_LOCK
31-
select ARCH_USE_CMPXCHG_LOCKREF
3231
select HAVE_ARCH_SOFT_DIRTY
3332
select MODULES_USE_ELF_RELA
3433
select NEED_DMA_MAP_STATE
@@ -118,6 +117,7 @@ config X86
118117
select ARCH_SUPPORTS_LTO_CLANG
119118
select ARCH_SUPPORTS_LTO_CLANG_THIN
120119
select ARCH_USE_BUILTIN_BSWAP
120+
select ARCH_USE_CMPXCHG_LOCKREF if X86_CMPXCHG64
121121
select ARCH_USE_MEMTEST
122122
select ARCH_USE_QUEUED_RWLOCKS
123123
select ARCH_USE_QUEUED_SPINLOCKS

0 commit comments

Comments
 (0)