Skip to content

Commit

Permalink
gettime: initialize cpusets properly
Browse files Browse the repository at this point in the history
We can't just use memset(), some platforms have specific init/exit
routines for cpusets/masks.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Jan 28, 2015
1 parent e66d7f9 commit c763aea
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions gettime.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c763aea

Please sign in to comment.