From c763aea6935a4a847f1d8869d9c700c0169973f7 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 28 Jan 2015 14:42:10 -0700 Subject: [PATCH] gettime: initialize cpusets properly We can't just use memset(), some platforms have specific init/exit routines for cpusets/masks. Signed-off-by: Jens Axboe --- gettime.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gettime.c b/gettime.c index f40abc7a..8419fe4b 100644 --- a/gettime.c +++ b/gettime.c @@ -477,14 +477,20 @@ static void *clock_thread_fn(void *data) uint32_t last_seq; int i; - memset(&cpu_mask, 0, sizeof(cpu_mask)); + if (fio_cpuset_init(&cpu_mask)) { + int __err; + + log_err("clock cpuset init failed: %s\n", strerror(__err)); + goto err_out; + } + fio_cpu_set(&cpu_mask, t->cpu); if (fio_setaffinity(gettid(), cpu_mask) == -1) { int __err = errno; log_err("clock setaffinity failed: %s\n", strerror(__err)); - return (void *) 1; + goto err; } pthread_mutex_lock(&t->lock); @@ -520,9 +526,13 @@ static void *clock_thread_fn(void *data) * indefinitely. Check for that and return failure. */ if (!t->entries[i - 1].tsc && !t->entries[0].tsc) - return (void *) 1; + goto err; return NULL; +err: + fio_cpuset_exit(&cpu_mask); +err_out: + return (void *) 1; } static int clock_cmp(const void *p1, const void *p2) -- 2.25.1