X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_urcu_defer.c;h=10cd250d2c9a3487f02c58f0e5135201ee3dbeda;hb=d8540fc53386cd7ff270085aca621e32772832ba;hp=1c6f742b13aa841b47f203c39fa633ecf3f6db61;hpb=ec4e58a3aba2084440012f8ccac3a31eb6101183;p=urcu.git diff --git a/tests/test_urcu_defer.c b/tests/test_urcu_defer.c index 1c6f742..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,12 +33,10 @@ #include #include #include +#include #include -/* Make this big enough to include the POWER5+ L3 cacheline size of 256B */ -#define CACHE_LINE_SIZE 4096 - /* hardcoded number of CPUs */ #define NR_CPUS 16384 @@ -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 */ } /* @@ -238,14 +250,14 @@ void *thr_writer(void *data) new = malloc(sizeof(*new)); new->a = 8; old = rcu_xchg_pointer(&test_rcu_pointer, new); - call_rcu(free, old); - call_rcu(test_cb1, old); - call_rcu(test_cb1, (void *)-2L); - call_rcu(test_cb1, (void *)-2L); - call_rcu(test_cb1, old); - call_rcu(test_cb2, (void *)-2L); - call_rcu(test_cb2, (void *)-4L); - call_rcu(test_cb2, (void *)-2L); + 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;