tests: move yield debug to common test library
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 15 Jan 2014 13:56:31 +0000 (08:56 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 15 Jan 2014 13:56:31 +0000 (08:56 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
22 files changed:
tests/benchmark/Makefile.am
tests/benchmark/test_mutex.c
tests/benchmark/test_perthreadlock.c
tests/benchmark/test_rwlock.c
tests/benchmark/test_urcu.c
tests/benchmark/test_urcu_assign.c
tests/benchmark/test_urcu_bp.c
tests/benchmark/test_urcu_defer.c
tests/benchmark/test_urcu_gc.c
tests/benchmark/test_urcu_hash.c
tests/benchmark/test_urcu_hash.h
tests/benchmark/test_urcu_qsbr.c
tests/benchmark/test_urcu_qsbr_gc.c
tests/common/Makefile.am
tests/common/debug-yield.c [new file with mode: 0644]
tests/common/debug-yield.h [new file with mode: 0644]
urcu.c
urcu/map/urcu-qsbr.h
urcu/map/urcu.h
urcu/static/urcu-bp.h
urcu/static/urcu-qsbr.h
urcu/static/urcu.h

index 175c9fc77c74f19f678cd7a7cbd0970229c981da..abcb5d5288dd867bca3baff0c80338df54c52eb7 100644 (file)
@@ -46,6 +46,8 @@ URCU_SIGNAL_LIB=$(top_builddir)/liburcu-signal.la
 URCU_BP_LIB=$(top_builddir)/liburcu-bp.la
 URCU_CDS_LIB=$(top_builddir)/liburcu-cds.la
 
+DEBUG_YIELD_LIB=$(builddir)/../common/libdebug-yield.la
+
 EXTRA_DIST = *.sh
 
 test_urcu_SOURCES = test_urcu.c $(URCU)
@@ -56,6 +58,7 @@ test_urcu_dynamic_link_CFLAGS = -DDYNAMIC_LINK_TEST $(AM_CFLAGS)
 test_urcu_timing_SOURCES = test_urcu_timing.c $(URCU)
 
 test_urcu_yield_SOURCES = test_urcu.c $(URCU)
+test_urcu_yield_LDADD = $(DEBUG_YIELD_LIB)
 test_urcu_yield_CFLAGS = -DDEBUG_YIELD $(AM_CFLAGS)
 
 
@@ -81,6 +84,7 @@ test_urcu_signal_timing_SOURCES = test_urcu_timing.c $(URCU_SIGNAL)
 test_urcu_signal_timing_CFLAGS= -DRCU_SIGNAL $(AM_CFLAGS)
 
 test_urcu_signal_yield_SOURCES = test_urcu.c $(URCU_SIGNAL)
+test_urcu_signal_yield_LDADD = $(DEBUG_YIELD_LIB)
 test_urcu_signal_yield_CFLAGS = -DRCU_SIGNAL -DDEBUG_YIELD $(AM_CFLAGS)
 
 test_rwlock_timing_SOURCES = test_rwlock_timing.c $(URCU_SIGNAL)
index 919654daa063d6589ec3e51ed99a8a8bc2c30a97..574d0e8cfce8efb3363c32c8acdae103113b27df 100644 (file)
@@ -43,8 +43,6 @@
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define debug_yield_read()
 #endif
 #include <urcu.h>
 
@@ -237,9 +235,6 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
-       printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -285,14 +280,6 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
-               case 'r':
-                       yield_active |= YIELD_READ;
-                       break;
-               case 'w':
-                       yield_active |= YIELD_WRITE;
-                       break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 01c4fb03f8e62add0e93d725a7472028b4128fd9..cc5f47dfa7345f530572e11e9b077154cbeed3ad 100644 (file)
@@ -43,8 +43,6 @@
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define debug_yield_read()
 #endif
 #include <urcu.h>
 
@@ -246,9 +244,6 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
-       printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -293,14 +288,6 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
-               case 'r':
-                       yield_active |= YIELD_READ;
-                       break;
-               case 'w':
-                       yield_active |= YIELD_WRITE;
-                       break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 32e3c39d99d25b5819339f4b2a4c8336ca6929eb..6f52e5fc7ef65e2d11376230bbd78604ccb35af8 100644 (file)
@@ -43,8 +43,6 @@
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define debug_yield_read()
 #endif
 #include <urcu.h>
 
@@ -233,9 +231,6 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
-       printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -281,14 +276,6 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
-               case 'r':
-                       yield_active |= YIELD_READ;
-                       break;
-               case 'w':
-                       yield_active |= YIELD_WRITE;
-                       break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index e87e235a5b1c7937e993f3a460b468b3455f224d..28dc75a4cbd49c2103a8bdbbd118c6d777c69aa4 100644 (file)
 #include <urcu/tls-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include <../common/debug-yield.h>
 
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define rcu_debug_yield_read()
 #endif
 #include <urcu.h>
 
@@ -247,9 +246,7 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -294,14 +291,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       rcu_yield_active |= RCU_YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       rcu_yield_active |= RCU_YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 6c4adc35f4f04ee25d702a46705cc5a897414b88..37b5f7a0c807e4fdba55d4e29b9ee7967bcf79c3 100644 (file)
 #include <urcu/tls-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include "../common/debug-yield.h"
 
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define rcu_debug_yield_read()
 #endif
 #include <urcu.h>
 
@@ -280,9 +279,7 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -327,14 +324,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       rcu_yield_active |= RCU_YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       rcu_yield_active |= RCU_YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 0f21da9bd09d1bd14d6d346d25f77bcfd38fa1f9..9c336e56a2d676047a2b592ce80486061bd5c0f3 100644 (file)
 #include <urcu/tls-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include "../common/debug-yield.h"
 
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define rcu_debug_yield_read()
 #endif
 #include <urcu-bp.h>
 
@@ -242,9 +241,7 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -289,14 +286,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       rcu_yield_active |= RCU_YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       rcu_yield_active |= RCU_YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 80249bdf767f0c6f8ab954b3c4746cd7c6874dd2..bc11941e5993c8ba4ef92b29cccae39a5a3f3f06 100644 (file)
 #include <urcu/tls-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include "../common/debug-yield.h"
 
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define rcu_debug_yield_read()
 #endif
 #include <urcu.h>
 #include <urcu-defer.h>
@@ -269,9 +268,7 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -316,14 +313,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       rcu_yield_active |= RCU_YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       rcu_yield_active |= RCU_YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 1375a5e230d57ecb1cbebdf69fd800d27b98e048..b9cda587553df146d39439ad828972ac314f3266 100644 (file)
 #include <urcu/tls-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include "../common/debug-yield.h"
 
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define rcu_debug_yield_read()
 #endif
 #include <urcu.h>
 
@@ -290,9 +289,7 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -337,14 +334,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       rcu_yield_active |= RCU_YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       rcu_yield_active |= RCU_YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index f862adbf92c58d827dfaf0fc1601ebe5a1c4b212..d610d05020c6539742895919e622c7f1ff06539d 100644 (file)
@@ -269,9 +269,7 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-v] (verbose output)\n");
@@ -348,14 +346,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       yield_active |= YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       yield_active |= YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index b35acdb88330d41c8ff2f73307730c181443bc32..a72248511c6b42d844df9d58f3b3ef3f63287dc2 100644 (file)
@@ -40,6 +40,7 @@
 #include <urcu/rand-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include "../common/debug-yield.h"
 
 #define DEFAULT_HASH_SIZE      32
 #define DEFAULT_MIN_ALLOC_SIZE 1
index e8ba5f6937470006645648e7b1677739a3248e49..c6a6098816d19404518a2a57965ba84ae323ed05 100644 (file)
 #include <urcu/tls-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include "../common/debug-yield.h"
 
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
 
 #ifndef DYNAMIC_LINK_TEST
 #define _LGPL_SOURCE
-#else
-#define rcu_debug_yield_read()
 #endif
 #include "urcu-qsbr.h"
 
@@ -253,9 +252,7 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
        printf("        [-e duration] (writer C.S. duration (in loops))\n");
@@ -300,14 +297,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       rcu_yield_active |= RCU_RCU_YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       rcu_yield_active |= RCU_RCU_YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 5fc15c0c6780dda2e216db8667e82b3fdb996c09..198dbb5070432f9b9a293a2ad0075e1d3822151c 100644 (file)
@@ -37,6 +37,7 @@
 #include <urcu/tls-compat.h>
 #include "cpuset.h"
 #include "thread-id.h"
+#include "../common/debug-yield.h"
 
 /* hardcoded number of CPUs */
 #define NR_CPUS 16384
@@ -289,9 +290,7 @@ void show_usage(int argc, char **argv)
        printf("Usage : %s nr_readers nr_writers duration (s) <OPTIONS>\n",
                argv[0]);
        printf("OPTIONS:\n");
-#ifdef DEBUG_YIELD
        printf("        [-r] [-w] (yield reader and/or writer)\n");
-#endif
        printf("        [-b batch] (batch reclaim)\n");
        printf("        [-d delay] (writer period (us))\n");
        printf("        [-c duration] (reader C.S. duration (in loops))\n");
@@ -337,14 +336,12 @@ int main(int argc, char **argv)
                if (argv[i][0] != '-')
                        continue;
                switch (argv[i][1]) {
-#ifdef DEBUG_YIELD
                case 'r':
-                       rcu_yield_active |= RCU_YIELD_READ;
+                       rcu_debug_yield_enable(RCU_YIELD_READ);
                        break;
                case 'w':
-                       rcu_yield_active |= RCU_YIELD_WRITE;
+                       rcu_debug_yield_enable(RCU_YIELD_WRITE);
                        break;
-#endif
                case 'a':
                        if (argc < i + 2) {
                                show_usage(argc, argv);
index 6e2327201473e36d892e56a687f485963c3c093f..b0a243b92c1cdbc7d13bc2ef85da0027439ccae6 100644 (file)
@@ -1,3 +1,7 @@
 noinst_HEADERS = cpuset.h thread-id.h
 
+noinst_LTLIBRARIES = libdebug-yield.la
+
+libdebug_yield_la_SOURCES = debug-yield.c debug-yield.h
+
 EXTRA_DIST = api.h
diff --git a/tests/common/debug-yield.c b/tests/common/debug-yield.c
new file mode 100644 (file)
index 0000000..8f06a9d
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * debug-yield.c
+ *
+ * Userspace RCU library tests - Debugging code
+ *
+ * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * IBM's contributions to this file may be relicensed under LGPLv2 or later.
+ */
+
+#include <urcu/tls-compat.h>
+#include "debug-yield.h"
+
+unsigned int rcu_yield_active;
+
+DEFINE_URCU_TLS(unsigned int, rcu_rand_yield);
diff --git a/tests/common/debug-yield.h b/tests/common/debug-yield.h
new file mode 100644 (file)
index 0000000..c60e4e0
--- /dev/null
@@ -0,0 +1,101 @@
+#ifndef URCU_TESTS_DEBUG_YIELD_H
+#define URCU_TESTS_DEBUG_YIELD_H
+
+/*
+ * debug-yield.h
+ *
+ * Userspace RCU library tests - Debugging header
+ *
+ * Copyright (c) 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) 2009 Paul E. McKenney, IBM Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * IBM's contributions to this file may be relicensed under LGPLv2 or later.
+ */
+
+#include <sched.h>
+#include <time.h>
+#include <pthread.h>
+#include <unistd.h>
+
+#define RCU_YIELD_READ         (1 << 0)
+#define RCU_YIELD_WRITE        (1 << 1)
+
+/*
+ * Updates with RCU_SIGNAL are much slower. Account this in the delay.
+ */
+#ifdef RCU_SIGNAL
+/* maximum sleep delay, in us */
+#define MAX_SLEEP 30000
+#else
+#define MAX_SLEEP 50
+#endif
+
+extern unsigned int rcu_yield_active;
+extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield);
+
+#ifdef DEBUG_YIELD
+static inline void rcu_debug_yield_read(void)
+{
+       if (rcu_yield_active & RCU_YIELD_READ)
+               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
+                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
+}
+
+static inline void rcu_debug_yield_write(void)
+{
+       if (rcu_yield_active & RCU_YIELD_WRITE)
+               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
+                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
+}
+
+static inline void rcu_debug_yield_enable(unsigned int flags)
+{
+       rcu_yield_active |= flags;
+}
+
+static inline void rcu_debug_yield_disable(unsigned int flags)
+{
+       rcu_yield_active &= ~flags;
+}
+
+static inline void rcu_debug_yield_init(void)
+{
+       URCU_TLS(rcu_rand_yield) = time(NULL) ^ (unsigned long) pthread_self();
+}
+#else /* DEBUG_YIELD */
+static inline void rcu_debug_yield_read(void)
+{
+}
+
+static inline void rcu_debug_yield_write(void)
+{
+}
+
+static inline void rcu_debug_yield_enable(unsigned int flags)
+{
+}
+
+static inline void rcu_debug_yield_disable(unsigned int flags)
+{
+}
+
+static inline void rcu_debug_yield_init(void)
+{
+}
+#endif
+
+#endif /* URCU_TESTS_DEBUG_YIELD_H */
diff --git a/urcu.c b/urcu.c
index 69ebcaa9cb0fbfa07a264ab94fa5261513c72424..a016bbda89db8ca970014728f24b24d738fb4464 100644 (file)
--- a/urcu.c
+++ b/urcu.c
@@ -109,11 +109,6 @@ struct rcu_gp rcu_gp = { .ctr = RCU_GP_COUNT };
  */
 DEFINE_URCU_TLS(struct rcu_reader, rcu_reader);
 
-#ifdef DEBUG_YIELD
-unsigned int rcu_yield_active;
-DEFINE_URCU_TLS(unsigned int, rcu_rand_yield);
-#endif
-
 static CDS_LIST_HEAD(registry);
 
 /*
index b89dd2487e34e35673e15879b7fe910b0e425679..9e90e3cd9322a839648a7aa6b31c0aec0f01b5d2 100644 (file)
@@ -76,7 +76,4 @@
 
 #define rcu_flavor                     rcu_flavor_qsbr
 
-#define rcu_yield_active               rcu_yield_active_memb_qsbr
-#define rcu_rand_yield                 rcu_rand_yield_memb_qsbr
-
 #endif /* _URCU_QSBR_MAP_H */
index 8f04cafcde5df141f84bd4f9067e0485147fd1d7..9a4bb1ab08af2f9db3cb9986b094dcf5e23ad1cc 100644 (file)
@@ -80,9 +80,6 @@
 
 #define rcu_flavor                     rcu_flavor_memb
 
-#define rcu_yield_active               rcu_yield_active_memb
-#define rcu_rand_yield                 rcu_rand_yield_memb
-
 /* Specific to MEMBARRIER flavor */
 #define rcu_has_sys_membarrier         rcu_has_sys_membarrier_memb
 
 
 #define rcu_flavor                     rcu_flavor_sig
 
-#define rcu_yield_active               rcu_yield_active_sig
-#define rcu_rand_yield                 rcu_rand_yield_sig
-
 #elif defined(RCU_MB)
 
 #define rcu_read_lock                  rcu_read_lock_mb
 
 #define rcu_flavor                     rcu_flavor_mb
 
-#define rcu_yield_active               rcu_yield_active_mb
-#define rcu_rand_yield                 rcu_rand_yield_mb
-
 #else
 
 #error "Undefined selection"
index 1052c44fad962efa7bb3b9781c3b6097a39257ac..b6d5f132778380c57af501307cf25e017c92c8ec 100644 (file)
@@ -64,58 +64,6 @@ enum rcu_state {
        RCU_READER_INACTIVE,
 };
 
-#ifdef DEBUG_YIELD
-#include <sched.h>
-#include <time.h>
-#include <pthread.h>
-#include <unistd.h>
-
-#define RCU_YIELD_READ         (1 << 0)
-#define RCU_YIELD_WRITE        (1 << 1)
-
-/*
- * Updates without RCU_MB are much slower. Account this in
- * the delay.
- */
-/* maximum sleep delay, in us */
-#define MAX_SLEEP 50
-
-extern unsigned int rcu_yield_active;
-extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield);
-
-static inline void rcu_debug_yield_read(void)
-{
-       if (rcu_yield_active & RCU_YIELD_READ)
-               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
-                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
-}
-
-static inline void rcu_debug_yield_write(void)
-{
-       if (rcu_yield_active & RCU_YIELD_WRITE)
-               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
-                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
-}
-
-static inline void rcu_debug_yield_init(void)
-{
-       URCU_TLS(rcu_rand_yield) = time(NULL) ^ (unsigned long) pthread_self();
-}
-#else
-static inline void rcu_debug_yield_read(void)
-{
-}
-
-static inline void rcu_debug_yield_write(void)
-{
-}
-
-static inline void rcu_debug_yield_init(void)
-{
-
-}
-#endif
-
 /*
  * The trick here is that RCU_GP_CTR_PHASE must be a multiple of 8 so we can use a
  * full 8-bits, 16-bits or 32-bits bitmask for the lower order bits.
index 690b77d528c38ef173aa1da91fc1d39dad0fed94..8f2ca32a2f111c4b1469c010c5f1fcb4669039a5 100644 (file)
@@ -68,54 +68,6 @@ enum rcu_state {
        RCU_READER_INACTIVE,
 };
 
-#ifdef DEBUG_YIELD
-#include <sched.h>
-#include <time.h>
-#include <pthread.h>
-#include <unistd.h>
-
-#define RCU_YIELD_READ         (1 << 0)
-#define RCU_YIELD_WRITE        (1 << 1)
-
-/* maximum sleep delay, in us */
-#define MAX_SLEEP 50
-
-extern unsigned int rcu_yield_active;
-extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield);
-
-static inline void rcu_debug_yield_read(void)
-{
-       if (rcu_yield_active & RCU_YIELD_READ)
-               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
-                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
-}
-
-static inline void rcu_debug_yield_write(void)
-{
-       if (rcu_yield_active & RCU_YIELD_WRITE)
-               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
-                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
-}
-
-static inline void rcu_debug_yield_init(void)
-{
-       URCU_TLS(rcu_rand_yield) = time(NULL) ^ (unsigned long) pthread_self();
-}
-#else
-static inline void rcu_debug_yield_read(void)
-{
-}
-
-static inline void rcu_debug_yield_write(void)
-{
-}
-
-static inline void rcu_debug_yield_init(void)
-{
-
-}
-#endif
-
 #define RCU_GP_ONLINE          (1UL << 0)
 #define RCU_GP_CTR             (1UL << 1)
 
index 33545b71f68c1be9dc25ef78a59a9a052d16aca5..b5fc09f93553578ae32f660b9c65a49a9ea3517f 100644 (file)
@@ -85,61 +85,6 @@ enum rcu_state {
 #define rcu_assert(args...)
 #endif
 
-#ifdef DEBUG_YIELD
-#include <sched.h>
-#include <time.h>
-#include <pthread.h>
-#include <unistd.h>
-
-#define RCU_YIELD_READ         (1 << 0)
-#define RCU_YIELD_WRITE        (1 << 1)
-
-/*
- * Updates with RCU_SIGNAL are much slower. Account this in the delay.
- */
-#ifdef RCU_SIGNAL
-/* maximum sleep delay, in us */
-#define MAX_SLEEP 30000
-#else
-#define MAX_SLEEP 50
-#endif
-
-extern unsigned int rcu_yield_active;
-extern DECLARE_URCU_TLS(unsigned int, rcu_rand_yield);
-
-static inline void rcu_debug_yield_read(void)
-{
-       if (rcu_yield_active & RCU_YIELD_READ)
-               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
-                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
-}
-
-static inline void rcu_debug_yield_write(void)
-{
-       if (rcu_yield_active & RCU_YIELD_WRITE)
-               if (rand_r(&URCU_TLS(rcu_rand_yield)) & 0x1)
-                       usleep(rand_r(&URCU_TLS(rcu_rand_yield)) % MAX_SLEEP);
-}
-
-static inline void rcu_debug_yield_init(void)
-{
-       URCU_TLS(rcu_rand_yield) = time(NULL) ^ (unsigned long) pthread_self();
-}
-#else
-static inline void rcu_debug_yield_read(void)
-{
-}
-
-static inline void rcu_debug_yield_write(void)
-{
-}
-
-static inline void rcu_debug_yield_init(void)
-{
-
-}
-#endif
-
 /*
  * RCU memory barrier broadcast group. Currently, only broadcast to all process
  * threads is supported (group 0).
This page took 0.039896 seconds and 4 git commands to generate.