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`
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.
[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:
# ~~~~
/* 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
#include <assert.h>
-#ifdef DEBUG_RCU
+#if defined(DEBUG_RCU) || defined(CONFIG_RCU_DEBUG)
#define urcu_assert(...) assert(__VA_ARGS__)
#else
#define urcu_assert(...)
* 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)
{
{
}
-#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);