Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3d0b4b1

Browse files
Use a non-locking initial test in TAS_SPIN on AArch64.
Our testing showed that this is helpful at sufficiently high contention levels and doesn't hurt performance on smaller machines. The new TAS_SPIN macro for AArch64 is identical to the ones added for PPC and x86_64 (see commits bc2a050 and b03d196). Reported-by: Salvatore Dipietro Reviewed-by: Jingtang Zhang, Andres Freund Tested-by: Tom Lane Discussion: https://postgr.es/m/ZxgDEb_VpWyNZKB_%40nathan
1 parent 28e7a99 commit 3d0b4b1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/include/storage/s_lock.h

+10-4
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,24 @@ tas(volatile slock_t *lock)
263263

264264
#define S_UNLOCK(lock) __sync_lock_release(lock)
265265

266+
#if defined(__aarch64__)
267+
266268
/*
267-
* Using an ISB instruction to delay in spinlock loops appears beneficial on
268-
* high-core-count ARM64 processors. It seems mostly a wash for smaller gear,
269-
* and ISB doesn't exist at all on pre-v7 ARM chips.
269+
* On ARM64, it's a win to use a non-locking test before the TAS proper. It
270+
* may be a win on 32-bit ARM, too, but nobody's tested it yet.
270271
*/
271-
#if defined(__aarch64__)
272+
#define TAS_SPIN(lock) (*(lock) ? 1 : TAS(lock))
272273

273274
#define SPIN_DELAY() spin_delay()
274275

275276
static __inline__ void
276277
spin_delay(void)
277278
{
279+
/*
280+
* Using an ISB instruction to delay in spinlock loops appears beneficial
281+
* on high-core-count ARM64 processors. It seems mostly a wash for smaller
282+
* gear, and ISB doesn't exist at all on pre-v7 ARM chips.
283+
*/
278284
__asm__ __volatile__(
279285
" isb; \n");
280286
}

0 commit comments

Comments
 (0)