Skip to content

Commit

Permalink
MINOR: plock: use an ARMv8 instruction barrier for the pause instruction
Browse files Browse the repository at this point in the history
As suggested by @AGSaidi in issue #958, on ARMv8 its convenient to use
an "isb" instruction in pl_cpu_relax() to improve fairness. Without it
I've met a few watchdog conditions on valid locks with 16 threads,
indicating that some threads couldn't manage to get it in 2 seconds. I
never happened again with it. In addition, the performance increased
by slightly more than 5% thanks to the reduced contention.

This should be backported as far as 2.2, possibly even 2.0.
  • Loading branch information
Your Name authored and wtarreau committed Nov 29, 2020
1 parent a9ffc41 commit 1e237d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/import/atomic-ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,21 @@
#else
/* generic implementations */

#if defined(__aarch64__)

/* This was shown to improve fairness on modern ARMv8 such as Neoverse N1 */
#define pl_cpu_relax() do { \
asm volatile("isb" ::: "memory"); \
} while (0)

#else

#define pl_cpu_relax() do { \
asm volatile(""); \
} while (0)

#endif

/* full memory barrier */
#define pl_mb() do { \
__sync_synchronize(); \
Expand Down

0 comments on commit 1e237d0

Please sign in to comment.