X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=stat.c;h=89d719468cd91aed185a3491e08cb1a1fe7d8313;hp=ccf08a64e9864ace1b1398618f29b2845e2bd649;hb=df5ad464a5cbec5a4e313038773e7943eb00e87b;hpb=aee2ab6775d96609a4632703827c409a7f9abcca diff --git a/stat.c b/stat.c index ccf08a64..89d71946 100644 --- a/stat.c +++ b/stat.c @@ -1169,7 +1169,7 @@ void init_thread_stat(struct thread_stat *ts) ts->groupid = -1; } -static void __show_run_stats(void) +void __show_run_stats(void) { struct group_run_stats *runstats, *rs; struct thread_data *td; @@ -1411,13 +1411,15 @@ void show_run_stats(void) fio_mutex_up(stat_mutex); } -static void *__show_running_run_stats(void fio_unused *arg) +static void *__show_running_run_stats(void *arg) { struct thread_data *td; unsigned long long *rt; struct timeval tv; int i; + fio_mutex_down(stat_mutex); + rt = malloc(thread_number * sizeof(unsigned long long)); fio_gettime(&tv, NULL); @@ -1458,6 +1460,7 @@ static void *__show_running_run_stats(void fio_unused *arg) free(rt); fio_mutex_up(stat_mutex); + free(arg); return NULL; } @@ -1468,21 +1471,23 @@ static void *__show_running_run_stats(void fio_unused *arg) */ void show_running_run_stats(void) { - pthread_t thread; + pthread_t *thread; - fio_mutex_down(stat_mutex); + thread = calloc(1, sizeof(*thread)); + if (!thread) + return; - if (!pthread_create(&thread, NULL, __show_running_run_stats, NULL)) { + if (!pthread_create(thread, NULL, __show_running_run_stats, thread)) { int err; - err = pthread_detach(thread); + err = pthread_detach(*thread); if (err) log_err("fio: DU thread detach failed: %s\n", strerror(err)); return; } - fio_mutex_up(stat_mutex); + free(thread); } static int status_interval_init; @@ -1603,7 +1608,7 @@ static void __add_log_sample(struct io_log *iolog, unsigned long val, s->val = val; s->time = t; - s->ddir = ddir; + io_sample_set_ddir(iolog, s, ddir); s->bs = bs; if (iolog->log_offset) {