X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_urcu_defer.c;h=10cd250d2c9a3487f02c58f0e5135201ee3dbeda;hb=d8540fc53386cd7ff270085aca621e32772832ba;hp=e56dffe2e308374dad1554b32013e3718309f4f1;hpb=786ee85b1676d2a1865b2db7120c45bafdf954d6;p=urcu.git diff --git a/tests/test_urcu_defer.c b/tests/test_urcu_defer.c index e56dffe..10cd250 100644 --- a/tests/test_urcu_defer.c +++ b/tests/test_urcu_defer.c @@ -21,6 +21,7 @@ */ #define _GNU_SOURCE +#include "../config.h" #include #include #include @@ -32,11 +33,9 @@ #include #include #include +#include -#include "../arch.h" - -/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */ -#define CACHE_LINE_SIZE 4096 +#include /* hardcoded number of CPUs */ #define NR_CPUS 16384 @@ -61,8 +60,8 @@ static inline pid_t gettid(void) #else #define debug_yield_read() #endif -#include "../urcu.h" -#include "../urcu-defer.h" +#include +#include struct test_array { int a; @@ -99,6 +98,12 @@ static int use_affinity = 0; pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; +#ifndef HAVE_CPU_SET_T +typedef unsigned long cpu_set_t; +# define CPU_ZERO(cpuset) do { *(cpuset) = 0; } while(0) +# define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0) +#endif + static void set_affinity(void) { cpu_set_t mask; @@ -108,6 +113,7 @@ static void set_affinity(void) if (!use_affinity) return; +#if HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); @@ -119,9 +125,15 @@ static void set_affinity(void) perror("Error in pthread mutex unlock"); exit(-1); } + CPU_ZERO(&mask); CPU_SET(cpu, &mask); +#if SCHED_SETAFFINITY_ARGS == 2 + sched_setaffinity(0, &mask); +#else sched_setaffinity(0, sizeof(mask), &mask); +#endif +#endif /* HAVE_SCHED_SETAFFINITY */ } /* @@ -209,6 +221,14 @@ void *thr_reader(void *_count) } +static void test_cb2(void *data) +{ +} + +static void test_cb1(void *data) +{ +} + void *thr_writer(void *data) { unsigned long wtidx = (unsigned long)data; @@ -230,7 +250,14 @@ void *thr_writer(void *data) new = malloc(sizeof(*new)); new->a = 8; old = rcu_xchg_pointer(&test_rcu_pointer, new); - rcu_defer_queue(old); + defer_rcu(free, old); + defer_rcu(test_cb1, old); + defer_rcu(test_cb1, (void *)-2L); + defer_rcu(test_cb1, (void *)-2L); + defer_rcu(test_cb1, old); + defer_rcu(test_cb2, (void *)-2L); + defer_rcu(test_cb2, (void *)-4L); + defer_rcu(test_cb2, (void *)-2L); nr_writes++; if (unlikely(!test_duration_write())) break;