X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_urcu_wfq.c;h=e042f5ec115eff39758af279f4d6049761b5d93e;hb=65fcc7e9957a1658327acd121c3d8c3b36f4a94e;hp=2399c7ad1055064952273316c53152ce6ea0bb51;hpb=ee566d46ed91f8e332460626573399237c312b4d;p=urcu.git diff --git a/tests/test_urcu_wfq.c b/tests/test_urcu_wfq.c index 2399c7a..e042f5e 100644 --- a/tests/test_urcu_wfq.c +++ b/tests/test_urcu_wfq.c @@ -34,12 +34,15 @@ #include #include #include -#include #include #include #include +#ifdef __linux__ +#include +#endif + /* hardcoded number of CPUs */ #define NR_CPUS 16384 @@ -62,8 +65,7 @@ static inline pid_t gettid(void) #define _LGPL_SOURCE #endif #include -#include -#include +#include static volatile int test_go, test_stop; @@ -77,7 +79,7 @@ static unsigned long wdelay; static inline void loop_sleep(unsigned long l) { while(l-- != 0) - cpu_relax(); + caa_cpu_relax(); } static int verbose_mode; @@ -154,7 +156,7 @@ static unsigned long long __thread nr_successful_enqueues; static unsigned int nr_enqueuers; static unsigned int nr_dequeuers; -static struct rcu_wfq_queue q; +static struct cds_wfq_queue q; void *thr_enqueuer(void *_count) { @@ -165,19 +167,17 @@ void *thr_enqueuer(void *_count) set_affinity(); - rcu_register_thread(); - while (!test_go) { } - smp_mb(); + cmm_smp_mb(); for (;;) { - struct rcu_wfq_node *node = malloc(sizeof(*node)); + struct cds_wfq_node *node = malloc(sizeof(*node)); if (!node) goto fail; - rcu_wfq_node_init(node); - rcu_wfq_enqueue(&q, node); + cds_wfq_node_init(node); + cds_wfq_enqueue(&q, node); nr_successful_enqueues++; if (unlikely(wdelay)) @@ -188,8 +188,6 @@ fail: break; } - rcu_unregister_thread(); - count[0] = nr_enqueues; count[1] = nr_successful_enqueues; printf_verbose("enqueuer thread_end, thread id : %lx, tid %lu, " @@ -200,14 +198,6 @@ fail: } -static void rcu_release_node(struct urcu_ref *ref) -{ - struct rcu_wfq_node *node = container_of(ref, struct rcu_wfq_node, ref); - defer_rcu(free, node); - //synchronize_rcu(); - //free(node); -} - void *thr_dequeuer(void *_count) { unsigned long long *count = _count; @@ -217,20 +207,16 @@ void *thr_dequeuer(void *_count) set_affinity(); - rcu_defer_register_thread(); - rcu_register_thread(); - while (!test_go) { } - smp_mb(); + cmm_smp_mb(); for (;;) { - struct rcu_wfq_node *node = - rcu_wfq_dequeue_blocking(&q, rcu_release_node); + struct cds_wfq_node *node = cds_wfq_dequeue_blocking(&q); if (node) { - urcu_ref_put(&node->ref, rcu_release_node); + free(node); nr_successful_dequeues++; } @@ -241,9 +227,6 @@ void *thr_dequeuer(void *_count) loop_sleep(rduration); } - rcu_unregister_thread(); - rcu_defer_unregister_thread(); - printf_verbose("dequeuer thread_end, thread id : %lx, tid %lu, " "dequeues %llu, successful_dequeues %llu\n", pthread_self(), (unsigned long)gettid(), nr_dequeues, @@ -253,20 +236,14 @@ void *thr_dequeuer(void *_count) return ((void*)2); } -static void release_node(struct urcu_ref *ref) -{ - struct rcu_wfq_node *node = container_of(ref, struct rcu_wfq_node, ref); - free(node); -} - -void test_end(struct rcu_wfq_queue *q, unsigned long long *nr_dequeues) +void test_end(struct cds_wfq_queue *q, unsigned long long *nr_dequeues) { - struct rcu_wfq_node *node; + struct cds_wfq_node *node; do { - node = rcu_wfq_dequeue_blocking(q, release_node); + node = cds_wfq_dequeue_blocking(q); if (node) { - urcu_ref_put(&node->ref, release_node); + free(node); (*nr_dequeues)++; } } while (node); @@ -363,7 +340,7 @@ int main(int argc, char **argv) tid_dequeuer = malloc(sizeof(*tid_dequeuer) * nr_dequeuers); count_enqueuer = malloc(2 * sizeof(*count_enqueuer) * nr_enqueuers); count_dequeuer = malloc(2 * sizeof(*count_dequeuer) * nr_dequeuers); - rcu_wfq_init(&q); + cds_wfq_init(&q); next_aff = 0; @@ -380,7 +357,7 @@ int main(int argc, char **argv) exit(1); } - smp_mb(); + cmm_smp_mb(); test_go = 1;