X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Ftest_urcu_defer.c;h=a711959a4ea19dbc19310f17d5450d54f6a96da4;hb=ab0aacbe1a25d50d069f0b24aa492e84ea296f57;hp=1575e9c3523a45e07d96e4eae59af99acad54d63;hpb=cc6b0c208a9707f8a64609a51167290caeace288;p=urcu.git diff --git a/tests/test_urcu_defer.c b/tests/test_urcu_defer.c index 1575e9c..a711959 100644 --- a/tests/test_urcu_defer.c +++ b/tests/test_urcu_defer.c @@ -35,6 +35,7 @@ #include #include +#include #ifdef __linux__ #include @@ -84,9 +85,9 @@ static unsigned long rduration; /* write-side C.S. duration, in loops */ static unsigned long wduration; -static inline void loop_sleep(unsigned long l) +static inline void loop_sleep(unsigned long loops) { - while(l-- != 0) + while (loops-- != 0) caa_cpu_relax(); } @@ -155,8 +156,8 @@ static int test_duration_read(void) return !test_stop; } -static unsigned long long __thread nr_writes; -static unsigned long long __thread nr_reads; +static DEFINE_URCU_TLS(unsigned long long, nr_writes); +static DEFINE_URCU_TLS(unsigned long long, nr_reads); static unsigned long long __attribute__((aligned(CAA_CACHE_LINE_SIZE))) *tot_nr_writes; @@ -213,14 +214,14 @@ void *thr_reader(void *_count) if (caa_unlikely(rduration)) loop_sleep(rduration); rcu_read_unlock(); - nr_reads++; + URCU_TLS(nr_reads)++; if (caa_unlikely(!test_duration_read())) break; } rcu_unregister_thread(); - *count = nr_reads; + *count = URCU_TLS(nr_reads); printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", "reader", pthread_self(), (unsigned long)gettid()); return ((void*)1); @@ -271,7 +272,7 @@ void *thr_writer(void *data) defer_rcu(test_cb2, (void *)-2L); defer_rcu(test_cb2, (void *)-4L); defer_rcu(test_cb2, (void *)-2L); - nr_writes++; + URCU_TLS(nr_writes)++; if (caa_unlikely(!test_duration_write())) break; if (caa_unlikely(wdelay)) @@ -282,7 +283,7 @@ void *thr_writer(void *data) printf_verbose("thread_end %s, thread id : %lx, tid %lu\n", "writer", pthread_self(), (unsigned long)gettid()); - tot_nr_writes[wtidx] = nr_writes; + tot_nr_writes[wtidx] = URCU_TLS(nr_writes); return ((void*)2); }