X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=stat.c;h=84d9eefd842e76ca6a1d96a482ad3fd2a4c251a7;hp=77e389cb1f7f85baa0c600a56adfc5e32c0274f7;hb=6f9961ac7aea504e8e89e9bc9c3a10f708f19318;hpb=9966af7bc3b881e814d337c2417c8033a8848a66 diff --git a/stat.c b/stat.c index 77e389cb..84d9eefd 100644 --- a/stat.c +++ b/stat.c @@ -1077,6 +1077,10 @@ void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src) dst->agg[i] += src->agg[i]; } + if (!dst->kb_base) + dst->kb_base = src->kb_base; + if (!dst->unit_base) + dst->unit_base = src->unit_base; } void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr) @@ -1418,7 +1422,7 @@ void show_run_stats(void) fio_mutex_up(stat_mutex); } -static void *__show_running_run_stats(void *arg) +void __show_running_run_stats(void) { struct thread_data *td; unsigned long long *rt; @@ -1447,6 +1451,8 @@ static void *__show_running_run_stats(void *arg) } for_each_td(td, i) { + if (td->runstate >= TD_EXITED) + continue; if (td->rusage_sem) { td->update_rusage = 1; fio_mutex_down(td->rusage_sem); @@ -1467,34 +1473,6 @@ static void *__show_running_run_stats(void *arg) free(rt); fio_mutex_up(stat_mutex); - free(arg); - return NULL; -} - -/* - * Called from signal handler. It _should_ be safe to just run this inline - * in the sig handler, but we should be disturbing the system less by just - * creating a thread to do it. - */ -void show_running_run_stats(void) -{ - pthread_t *thread; - - thread = calloc(1, sizeof(*thread)); - if (!thread) - return; - - if (!pthread_create(thread, NULL, __show_running_run_stats, thread)) { - int err; - - err = pthread_detach(*thread); - if (err) - log_err("fio: DU thread detach failed: %s\n", strerror(err)); - - return; - } - - free(thread); } static int status_interval_init; @@ -1913,3 +1891,12 @@ void stat_exit(void) fio_mutex_down(stat_mutex); fio_mutex_remove(stat_mutex); } + +/* + * Called from signal handler. Wake up status thread. + */ +void show_running_run_stats(void) +{ + helper_do_stat = 1; + pthread_cond_signal(&helper_cond); +}