From: Mathieu Desnoyers Date: Tue, 15 Sep 2009 18:36:55 +0000 (-0400) Subject: urcu qsbr: add DEBUG_RCU self check X-Git-Tag: v0.1~94 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fb6e510b9ae45b9b984b4646b4be6b9d7a2bbf7c;p=urcu.git urcu qsbr: add DEBUG_RCU self check Signed-off-by: Mathieu Desnoyers --- 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)