From: Jonathan Rajotte Date: Mon, 23 Jan 2017 19:26:59 +0000 (-0500) Subject: Add --enable-rcu-debug to configure X-Git-Tag: v0.10.0~12 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d4e640c06c2c999d5fc8f8375bc2f61da06c9cda;p=userspace-rcu.git Add --enable-rcu-debug to configure When used CONFIG_RCU_DEBUG is defined in urcu/config.h, thus the debugging self-test are used at all time. This enables a permanent built-in debugging behaviour. Signed-off-by: Jonathan Rajotte Signed-off-by: Mathieu Desnoyers --- diff --git a/README.md b/README.md index 7ce0edf..4615746 100644 --- a/README.md +++ b/README.md @@ -358,12 +358,19 @@ can be forced by specifying `--disable-compiler-tls` as configure argument. -### Usage of `DEBUG_RCU` +### Usage of `DEBUG_RCU` & `--enable-rcu-debug` -`DEBUG_RCU` is used to add internal debugging self-checks to the -RCU library. This define adds a performance penalty when enabled. -Can be enabled by uncommenting the corresponding line in -`Makefile.build.inc`. +By default the library is configured with internal debugging +self-checks disabled. + +For always-on debugging self-checks: + ./configure --enable-rcu-debug + +For fine grained enabling of debugging self-checks, build +urserspace-rcu with DEBUG_RCU defined and compile dependent +applications with DEBUG_RCU defined when necessary. + +Warning: Enabling this feature result in a performance penalty. ### Usage of `DEBUG_YIELD` diff --git a/configure.ac b/configure.ac index 8ac0c41..dcbb61f 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ AH_TEMPLATE([CONFIG_RCU_ARM_HAVE_DMB], [Use the dmb instruction if available for AH_TEMPLATE([CONFIG_RCU_TLS], [TLS provided by the compiler.]) AH_TEMPLATE([CONFIG_RCU_HAVE_CLOCK_GETTIME], [clock_gettime() is detected.]) AH_TEMPLATE([CONFIG_RCU_FORCE_SYS_MEMBARRIER], [Require the operating system to support the membarrier system call for default and bulletproof flavors.]) +AH_TEMPLATE([CONFIG_RCU_DEBUG], [Enable internal debugging self-checks. Introduce performance penalty.]) # Allow requiring the operating system to support the membarrier system # call. Applies to default and bulletproof flavors. @@ -253,6 +254,13 @@ AC_ARG_ENABLE([smp-support], [def_smp_support="yes"]) AS_IF([test "x$def_smp_support" = "xyes"], [AC_DEFINE([CONFIG_RCU_SMP], [1])]) +# RCU debugging option +AC_ARG_ENABLE([rcu-debug], + AS_HELP_STRING([--enable-rcu-debug], [Enable internal debugging + self-checks. Introduce performance penalty.])) +AS_IF([test "x$enable_rcu_debug" = "xyes"], [ + AC_DEFINE([CONFIG_RCU_DEBUG], [1]) +]) # From the sched_setaffinity(2)'s man page: # ~~~~ diff --git a/include/urcu/config.h.in b/include/urcu/config.h.in index bb128a1..9ed0454 100644 --- a/include/urcu/config.h.in +++ b/include/urcu/config.h.in @@ -26,3 +26,7 @@ /* Require the operating system to support the membarrier system call for default and bulletproof flavors. */ #undef CONFIG_RCU_FORCE_SYS_MEMBARRIER + +/* Enable internal debugging self-checks. + Introduce performance penalty. */ +#undef CONFIG_RCU_DEBUG diff --git a/include/urcu/debug.h b/include/urcu/debug.h index 327bd92..14b50b6 100644 --- a/include/urcu/debug.h +++ b/include/urcu/debug.h @@ -21,7 +21,7 @@ #include -#ifdef DEBUG_RCU +#if defined(DEBUG_RCU) || defined(CONFIG_RCU_DEBUG) #define urcu_assert(...) assert(__VA_ARGS__) #else #define urcu_assert(...) diff --git a/src/urcu-qsbr.h b/src/urcu-qsbr.h index bf17361..5e47ad6 100644 --- a/src/urcu-qsbr.h +++ b/src/urcu-qsbr.h @@ -90,12 +90,14 @@ extern "C" { * QSBR read lock/unlock are guaranteed to be no-ops. Therefore, we expose them * in the LGPL header for any code to use. However, the debug version is not * nops and may contain sanity checks. To activate it, applications must be - * recompiled with -DDEBUG_RCU (even non-LGPL/GPL applications). This is the - * best trade-off between license/performance/code triviality and - * library debugging & tracing features we could come up with. + * recompiled with -DDEBUG_RCU (even non-LGPL/GPL applications), or + * compiled against a urcu/config.h that has CONFIG_RCU_DEBUG defined. + * This is the best trade-off between license/performance/code + * triviality and library debugging & tracing features we could come up + * with. */ -#if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU)) +#if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) static inline void rcu_read_lock(void) { @@ -105,12 +107,12 @@ static inline void rcu_read_unlock(void) { } -#else /* !DEBUG_RCU */ +#else /* #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */ extern void rcu_read_lock(void); extern void rcu_read_unlock(void); -#endif /* !DEBUG_RCU */ +#endif /* #else #if (!defined(BUILD_QSBR_LIB) && !defined(DEBUG_RCU) && !defined(CONFIG_RCU_DEBUG)) */ extern int rcu_read_ongoing(void); extern void rcu_quiescent_state(void);