X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fbenchmark%2Ftest_urcu_wfq.c;h=8381160fe8ecd95c0238984137cf861bcb46eafd;hb=014775106c60f02818ca755b331f887030bd440f;hp=76821047104a9660edd6cc439ee723f937fe3c21;hpb=83e334d03eaba62df373cf44298616458900078a;p=userspace-rcu.git diff --git a/tests/benchmark/test_urcu_wfq.c b/tests/benchmark/test_urcu_wfq.c index 7682104..8381160 100644 --- a/tests/benchmark/test_urcu_wfq.c +++ b/tests/benchmark/test_urcu_wfq.c @@ -31,12 +31,11 @@ #include #include #include -#include #include #include +#include #include -#include "cpuset.h" #include "thread-id.h" /* hardcoded number of CPUs */ @@ -83,7 +82,7 @@ pthread_mutex_t affinity_mutex = PTHREAD_MUTEX_INITIALIZER; static void set_affinity(void) { -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY cpu_set_t mask; int cpu, ret; #endif /* HAVE_SCHED_SETAFFINITY */ @@ -91,7 +90,7 @@ static void set_affinity(void) if (!use_affinity) return; -#if HAVE_SCHED_SETAFFINITY +#ifdef HAVE_SCHED_SETAFFINITY ret = pthread_mutex_lock(&affinity_mutex); if (ret) { perror("Error in pthread mutex lock"); @@ -106,11 +105,7 @@ static void set_affinity(void) 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 */ } @@ -138,6 +133,7 @@ static unsigned int nr_dequeuers; static struct cds_wfq_queue q; +static void *thr_enqueuer(void *_count) { unsigned long long *count = _count; @@ -179,6 +175,7 @@ fail: } +static void *thr_dequeuer(void *_count) { unsigned long long *count = _count; @@ -218,20 +215,22 @@ void *thr_dequeuer(void *_count) return ((void*)2); } -void test_end(struct cds_wfq_queue *q, unsigned long long *nr_dequeues) +static +void test_end(unsigned long long *nr_dequeues_l) { struct cds_wfq_node *node; do { - node = cds_wfq_dequeue_blocking(q); + node = cds_wfq_dequeue_blocking(&q); if (node) { free(node); - (*nr_dequeues)++; + (*nr_dequeues_l)++; } } while (node); } -void show_usage(int argc, char **argv) +static +void show_usage(char **argv) { printf("Usage : %s nr_dequeuers nr_enqueuers duration (s) \n", argv[0]); @@ -257,25 +256,25 @@ int main(int argc, char **argv) unsigned int i_thr; if (argc < 4) { - show_usage(argc, argv); + show_usage(argv); return -1; } err = sscanf(argv[1], "%u", &nr_dequeuers); if (err != 1) { - show_usage(argc, argv); + show_usage(argv); return -1; } err = sscanf(argv[2], "%u", &nr_enqueuers); if (err != 1) { - show_usage(argc, argv); + show_usage(argv); return -1; } err = sscanf(argv[3], "%lu", &duration); if (err != 1) { - show_usage(argc, argv); + show_usage(argv); return -1; } @@ -285,7 +284,7 @@ int main(int argc, char **argv) switch (argv[i][1]) { case 'a': if (argc < i + 2) { - show_usage(argc, argv); + show_usage(argv); return -1; } a = atoi(argv[++i]); @@ -295,14 +294,14 @@ int main(int argc, char **argv) break; case 'c': if (argc < i + 2) { - show_usage(argc, argv); + show_usage(argv); return -1; } rduration = atol(argv[++i]); break; case 'd': if (argc < i + 2) { - show_usage(argc, argv); + show_usage(argv); return -1; } wdelay = atol(argv[++i]); @@ -371,7 +370,7 @@ int main(int argc, char **argv) tot_successful_dequeues += count_dequeuer[2 * i_thr + 1]; } - test_end(&q, &end_dequeues); + test_end(&end_dequeues); printf_verbose("total number of enqueues : %llu, dequeues %llu\n", tot_enqueues, tot_dequeues);