From 93e3c9abce1a02ac724afa382751852fa5edf713 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 29 Mar 2017 13:44:03 +0200 Subject: libglusterfs: provide standardized atomic operations The current macros ATOMIC_INCREMENT() and ATOMIC_DECREMENT() expect a lock as first argument. There are at least two issues with this approach: 1. this lock is unused on architectures that have atomic operations 2. some structures use a single lock for multiple variables By defining a gf_atomic_t type, the unused lock can be removed, saving a few bytes on modern architectures. Because the gf_atomic_t type locates the lock for the variable (in case of older architectures), each variable is protected the same on all architectures. This makes the behaviour across all architectures more equal (per variable locking, by a gf_lock_t or compiler optimization). BUG: 1437037 Change-Id: Ic164892b06ea676e6a9566f8a98b7faf0efe76d6 Signed-off-by: Niels de Vos Reviewed-on: https://review.gluster.org/16963 Smoke: Gluster Build System Reviewed-by: Xavier Hernandez NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Amar Tumballi Reviewed-by: Jeff Darcy --- xlators/debug/io-stats/src/io-stats.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'xlators/debug/io-stats/src/io-stats.c') diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index d3b3136d982..7af7b528f88 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -249,7 +249,13 @@ is_fop_latency_started (call_frame_t *frame) conf->incremental.fop_hits[GF_FOP_##op]++; \ } while (0) -#if defined(HAVE_ATOMIC_BUILTINS) +#if defined(HAVE_SYNC_BUILTINS) +/* FIXME: use gf_atomic_t from libglusterfs/src/atomic.h + * + * This is currently not behaving correctly. Values are going out of sync in + * the case where HAVE_SYNC_BUILTINS are available, but are updated under a + * single lock for other cases. + */ #define STATS_LOCK(x) #define STATS_UNLOCK(x) #define STATS_ADD(x,i) __sync_add_and_fetch (&x, i) -- cgit