From fb6e510b9ae45b9b984b4646b4be6b9d7a2bbf7c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 15 Sep 2009 14:36:55 -0400 Subject: [PATCH] urcu qsbr: add DEBUG_RCU self check Signed-off-by: Mathieu Desnoyers --- Makefile.build.inc | 13 ++++++++++--- README | 2 ++ urcu-qsbr.h | 8 ++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Makefile.build.inc b/Makefile.build.inc index fc4c471..56c7705 100644 --- a/Makefile.build.inc +++ b/Makefile.build.inc @@ -1,7 +1,14 @@ -CFLAGS=-Wall -O2 -g -I. -#debug -#CFLAGS=-Wall -g +CFLAGS=-Wall -I. + +#optimized +CFLAGS+=-O2 + +#debug information +CFLAGS+=-g + +#RCU debug (slower, with error-checks) +#CFLAGS+=-DDEBUG_RCU LDFLAGS=-lpthread diff --git a/README b/README index 0ec723d..f9af1eb 100644 --- a/README +++ b/README @@ -53,6 +53,8 @@ Usage of DEBUG_RCU DEBUG_RCU is used to add internal debugging self-checks to the RCU library. This define adds a performance penality when enabled. + Can be enabled by uncommenting the corresponding line in + Makefile.build.inc. Usage of DEBUG_YIELD diff --git a/urcu-qsbr.h b/urcu-qsbr.h index f5392a3..448074d 100644 --- a/urcu-qsbr.h +++ b/urcu-qsbr.h @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -108,6 +109,12 @@ */ #define KICK_READER_LOOPS 10000 +#ifdef DEBUG_RCU +#define rcu_assert(args...) assert(args) +#else +#define rcu_assert(args...) +#endif + #ifdef DEBUG_YIELD #include #include @@ -180,6 +187,7 @@ static inline int rcu_gp_ongoing(long *value) static inline void _rcu_read_lock(void) { + rcu_assert(rcu_reader_qs_gp & 1); } static inline void _rcu_read_unlock(void) -- 2.34.1