From 508e92d2fca2606a530421032a468f91a39e43ae Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Mon, 26 Jan 2015 18:51:15 -0500 Subject: [PATCH] ck_backoff: Remove usage of volatile. This avoids memory traffic in busy-wait loops. Been on TODO list for a while, may as well bite the bullet. No regressions introduced in recent versions of GCC, clang and ICC. --- include/ck_backoff.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/ck_backoff.h b/include/ck_backoff.h index 9e43847..cf3045c 100644 --- a/include/ck_backoff.h +++ b/include/ck_backoff.h @@ -28,6 +28,7 @@ #define _CK_BACKOFF_H #include +#include #ifndef CK_BACKOFF_CEILING #define CK_BACKOFF_CEILING ((1 << 20) - 1) @@ -35,20 +36,19 @@ #define CK_BACKOFF_INITIALIZER (1 << 9) -typedef volatile unsigned int ck_backoff_t; +typedef unsigned int ck_backoff_t; /* * This is a exponential back-off implementation. */ CK_CC_INLINE static void -ck_backoff_eb(volatile unsigned int *c) +ck_backoff_eb(unsigned int *c) { - volatile unsigned int i; - unsigned int ceiling; + unsigned int i, ceiling; ceiling = *c; - - for (i = 0; i < ceiling; i++); + for (i = 0; i < ceiling; i++) + ck_pr_barrier(); *c = ceiling <<= ceiling < CK_BACKOFF_CEILING; return;