Skip to content

Commit

Permalink
Fix performance regression in Qthreads 1.21 by adjusting the exact ty…
Browse files Browse the repository at this point in the history
…pe of fencing we do for spinlocks.
  • Loading branch information
insertinterestingnamehere committed Oct 24, 2024
1 parent f2b88c5 commit ad176e5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion include/qt_atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@
#define THREAD_FENCE_MEM_RELEASE THREAD_FENCE_MEM_RELEASE_IMPL
#endif

#if QTHREAD_ASSEMBLY_ARCH == QTHREAD_IA32 || \
QTHREAD_ASSEMBLY_ARCH == QTHREAD_AMD64
#define SPINLOCK_BODY() \
do { MACHINE_FENCE; } while (0)
do { __asm__ __volatile__("pause" ::: "memory"); } while (0)
#elif QTHREAD_ASSEMBLY_ARCH == QTHREAD_ARM || \
QTHREAD_ASSEMBLY_ARCH == QTHREAD_ARMV8_A64
#define SPINLOCK_BODY() \
do { __asm__ __volatile__("yield" ::: "memory"); } while (0)
#else
#define SPINLOCK_BODY() \
do { atomic_thread_fence(memory_order_acq_rel; \
} while (0)
#endif

#define QTHREAD_FASTLOCK_SETUP() \
do { \
Expand Down

0 comments on commit ad176e5

Please sign in to comment.