From 6202c70d8d5cbdd3fb4bc23b96f691cbd25a327e Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 30 Mar 2021 20:13:16 -0600 Subject: [PATCH] gettime: cleanup ifdef mess Let's just set mask to all CPUs for the non-affinity case, and we can use the same mask test case throughout. Signed-off-by: Jens Axboe --- gettime.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gettime.c b/gettime.c index 7671ba9a..e3f483a7 100644 --- a/gettime.c +++ b/gettime.c @@ -677,10 +677,14 @@ int fio_monotonic_clocktest(int debug) struct clock_entry *prev, *this; uint32_t seq = 0; unsigned int i; -#ifdef CONFIG_PTHREAD_GETAFFINITY os_cpu_mask_t mask; +#ifdef CONFIG_PTHREAD_GETAFFINITY fio_get_thread_affinity(mask); +#else + memset(&mask, 0, sizeof(mask)); + for (i = 0; i < nr_cpus; i++) + fio_cpu_set(&mask, i); #endif if (debug) { @@ -712,10 +716,8 @@ int fio_monotonic_clocktest(int debug) for (i = 0; i < nr_cpus; i++) { struct clock_thread *t = &cthreads[i]; -#ifdef CONFIG_PTHREAD_GETAFFINITY if (!fio_cpu_isset(&mask, i)) continue; -#endif t->cpu = i; t->debug = debug; t->seq = &seq; @@ -732,20 +734,18 @@ int fio_monotonic_clocktest(int debug) for (i = 0; i < nr_cpus; i++) { struct clock_thread *t = &cthreads[i]; -#ifdef CONFIG_PTHREAD_GETAFFINITY + if (!fio_cpu_isset(&mask, i)) continue; -#endif fio_sem_up(&t->lock); } for (i = 0; i < nr_cpus; i++) { struct clock_thread *t = &cthreads[i]; void *ret; -#ifdef CONFIG_PTHREAD_GETAFFINITY + if (!fio_cpu_isset(&mask, i)) continue; -#endif pthread_join(t->thread, &ret); if (ret) failed++; @@ -759,9 +759,7 @@ int fio_monotonic_clocktest(int debug) goto err; } -#ifdef CONFIG_PTHREAD_GETAFFINITY tentries = nr_entries * seen_cpus; -#endif qsort(entries, tentries, sizeof(struct clock_entry), clock_cmp); /* silence silly gcc */ -- 2.25.1