From: Mathieu Desnoyers Date: Wed, 15 Jan 2014 13:56:31 +0000 (-0500) Subject: tests: move yield debug to common test library X-Git-Tag: v0.9.0~111 X-Git-Url: https://git.lttng.org/?p=urcu.git;a=commitdiff_plain;h=2650042a5405028da49bfcfb71053b78a56a9ed4 tests: move yield debug to common test library Signed-off-by: Mathieu Desnoyers --- diff --git a/tests/benchmark/Makefile.am b/tests/benchmark/Makefile.am index 175c9fc..abcb5d5 100644 --- a/tests/benchmark/Makefile.am +++ b/tests/benchmark/Makefile.am @@ -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) diff --git a/tests/benchmark/test_mutex.c b/tests/benchmark/test_mutex.c index 919654d..574d0e8 100644 --- a/tests/benchmark/test_mutex.c +++ b/tests/benchmark/test_mutex.c @@ -43,8 +43,6 @@ #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE -#else -#define debug_yield_read() #endif #include @@ -237,9 +235,6 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_perthreadlock.c b/tests/benchmark/test_perthreadlock.c index 01c4fb0..cc5f47d 100644 --- a/tests/benchmark/test_perthreadlock.c +++ b/tests/benchmark/test_perthreadlock.c @@ -43,8 +43,6 @@ #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE -#else -#define debug_yield_read() #endif #include @@ -246,9 +244,6 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_rwlock.c b/tests/benchmark/test_rwlock.c index 32e3c39..6f52e5f 100644 --- a/tests/benchmark/test_rwlock.c +++ b/tests/benchmark/test_rwlock.c @@ -43,8 +43,6 @@ #ifndef DYNAMIC_LINK_TEST #define _LGPL_SOURCE -#else -#define debug_yield_read() #endif #include @@ -233,9 +231,6 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_urcu.c b/tests/benchmark/test_urcu.c index e87e235..28dc75a 100644 --- a/tests/benchmark/test_urcu.c +++ b/tests/benchmark/test_urcu.c @@ -37,14 +37,13 @@ #include #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 @@ -247,9 +246,7 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_urcu_assign.c b/tests/benchmark/test_urcu_assign.c index 6c4adc3..37b5f7a 100644 --- a/tests/benchmark/test_urcu_assign.c +++ b/tests/benchmark/test_urcu_assign.c @@ -37,14 +37,13 @@ #include #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 @@ -280,9 +279,7 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_urcu_bp.c b/tests/benchmark/test_urcu_bp.c index 0f21da9..9c336e5 100644 --- a/tests/benchmark/test_urcu_bp.c +++ b/tests/benchmark/test_urcu_bp.c @@ -37,14 +37,13 @@ #include #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 @@ -242,9 +241,7 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_urcu_defer.c b/tests/benchmark/test_urcu_defer.c index 80249bd..bc11941 100644 --- a/tests/benchmark/test_urcu_defer.c +++ b/tests/benchmark/test_urcu_defer.c @@ -37,14 +37,13 @@ #include #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 #include @@ -269,9 +268,7 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_urcu_gc.c b/tests/benchmark/test_urcu_gc.c index 1375a5e..b9cda58 100644 --- a/tests/benchmark/test_urcu_gc.c +++ b/tests/benchmark/test_urcu_gc.c @@ -37,14 +37,13 @@ #include #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 @@ -290,9 +289,7 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_urcu_hash.c b/tests/benchmark/test_urcu_hash.c index f862adb..d610d05 100644 --- a/tests/benchmark/test_urcu_hash.c +++ b/tests/benchmark/test_urcu_hash.c @@ -269,9 +269,7 @@ void show_usage(int argc, char **argv) printf("Usage : %s nr_readers nr_writers duration (s) \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); diff --git a/tests/benchmark/test_urcu_hash.h b/tests/benchmark/test_urcu_hash.h index b35acdb..a722485 100644 --- a/tests/benchmark/test_urcu_hash.h +++ b/tests/benchmark/test_urcu_hash.h @@ -40,6 +40,7 @@ #include #include "cpuset.h" #include "thread-id.h" +#include "../common/debug-yield.h" #define DEFAULT_HASH_SIZE 32 #define DEFAULT_MIN_ALLOC_SIZE 1 diff --git a/tests/benchmark/test_urcu_qsbr.c b/tests/benchmark/test_urcu_qsbr.c index e8ba5f6..c6a6098 100644 --- a/tests/benchmark/test_urcu_qsbr.c +++ b/tests/benchmark/test_urcu_qsbr.c @@ -37,14 +37,13 @@ #include #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) \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); diff --git a/tests/benchmark/test_urcu_qsbr_gc.c b/tests/benchmark/test_urcu_qsbr_gc.c index 5fc15c0..198dbb5 100644 --- a/tests/benchmark/test_urcu_qsbr_gc.c +++ b/tests/benchmark/test_urcu_qsbr_gc.c @@ -37,6 +37,7 @@ #include #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) \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); diff --git a/tests/common/Makefile.am b/tests/common/Makefile.am index 6e23272..b0a243b 100644 --- a/tests/common/Makefile.am +++ b/tests/common/Makefile.am @@ -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 index 0000000..8f06a9d --- /dev/null +++ b/tests/common/debug-yield.c @@ -0,0 +1,31 @@ +/* + * debug-yield.c + * + * Userspace RCU library tests - Debugging code + * + * Copyright (c) 2009 Mathieu Desnoyers + * 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 +#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 index 0000000..c60e4e0 --- /dev/null +++ b/tests/common/debug-yield.h @@ -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 + * 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 +#include +#include +#include + +#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 69ebcaa..a016bbd 100644 --- 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); /* diff --git a/urcu/map/urcu-qsbr.h b/urcu/map/urcu-qsbr.h index b89dd24..9e90e3c 100644 --- a/urcu/map/urcu-qsbr.h +++ b/urcu/map/urcu-qsbr.h @@ -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 */ diff --git a/urcu/map/urcu.h b/urcu/map/urcu.h index 8f04caf..9a4bb1a 100644 --- a/urcu/map/urcu.h +++ b/urcu/map/urcu.h @@ -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 @@ -128,9 +125,6 @@ #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 @@ -173,9 +167,6 @@ #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" diff --git a/urcu/static/urcu-bp.h b/urcu/static/urcu-bp.h index 1052c44..b6d5f13 100644 --- a/urcu/static/urcu-bp.h +++ b/urcu/static/urcu-bp.h @@ -64,58 +64,6 @@ enum rcu_state { RCU_READER_INACTIVE, }; -#ifdef DEBUG_YIELD -#include -#include -#include -#include - -#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. diff --git a/urcu/static/urcu-qsbr.h b/urcu/static/urcu-qsbr.h index 690b77d..8f2ca32 100644 --- a/urcu/static/urcu-qsbr.h +++ b/urcu/static/urcu-qsbr.h @@ -68,54 +68,6 @@ enum rcu_state { RCU_READER_INACTIVE, }; -#ifdef DEBUG_YIELD -#include -#include -#include -#include - -#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) diff --git a/urcu/static/urcu.h b/urcu/static/urcu.h index 33545b7..b5fc09f 100644 --- a/urcu/static/urcu.h +++ b/urcu/static/urcu.h @@ -85,61 +85,6 @@ enum rcu_state { #define rcu_assert(args...) #endif -#ifdef DEBUG_YIELD -#include -#include -#include -#include - -#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).