Use a non-locking initial test in TAS_SPIN on PPC.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 3 Jan 2012 21:00:06 +0000 (16:00 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 3 Jan 2012 21:00:06 +0000 (16:00 -0500)
Further testing convinces me that this is helpful at sufficiently high
contention levels, though it's still worrisome that it loses slightly
at lower contention levels.

Per Manabu Ori.

src/include/storage/s_lock.h

index ff7eb1418e63b19b3396485b4725e1fc06ca8441..9b02d1f5a409c7309d4ba71aa4301b6d31d194d3 100644 (file)
@@ -358,6 +358,9 @@ typedef unsigned int slock_t;
 
 #define TAS(lock) tas(lock)
 
+/* On PPC, it's a win to use a non-locking test before the lwarx */
+#define TAS_SPIN(lock) (*(lock) ? 1 : TAS(lock))
+
 /*
  * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
  * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.