From: Jens Axboe Date: Mon, 7 Dec 2015 21:30:34 +0000 (-0700) Subject: Fix stat summing for unified_rw_reporting X-Git-Tag: fio-2.2.13~40 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=fd595830408b43beabbd94c8ad3d10e1f68356dd Fix stat summing for unified_rw_reporting Signed-off-by: Jens Axboe --- diff --git a/client.c b/client.c index db472c4c..2cba8a03 100644 --- a/client.c +++ b/client.c @@ -946,7 +946,7 @@ static void handle_ts(struct fio_client *client, struct fio_net_cmd *cmd) if (sum_stat_clients <= 1) return; - sum_thread_stats(&client_ts, &p->ts, sum_stat_nr); + sum_thread_stats(&client_ts, &p->ts, sum_stat_nr == 1); sum_group_stats(&client_gs, &p->rs); client_ts.members++; diff --git a/gclient.c b/gclient.c index d7d9616e..17af38ab 100644 --- a/gclient.c +++ b/gclient.c @@ -296,7 +296,7 @@ static void gfio_thread_status_op(struct fio_client *client, if (sum_stat_clients == 1) return; - sum_thread_stats(&client_ts, &p->ts, sum_stat_nr); + sum_thread_stats(&client_ts, &p->ts, sum_stat_nr == 1); sum_group_stats(&client_gs, &p->rs); client_ts.members++; diff --git a/stat.c b/stat.c index e5ec2237..818756dd 100644 --- a/stat.c +++ b/stat.c @@ -1253,7 +1253,7 @@ struct json_object *show_thread_status(struct thread_stat *ts, return ret; } -static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr) +static void sum_stat(struct io_stat *dst, struct io_stat *src, bool first) { double mean, S; @@ -1268,7 +1268,7 @@ static void sum_stat(struct io_stat *dst, struct io_stat *src, int nr) * */ - if (nr == 1) { + if (first) { mean = src->mean.u.f; S = src->S.u.f; } else { @@ -1312,31 +1312,38 @@ void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src) dst->unit_base = src->unit_base; } -void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr) +void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, + bool first) { int l, k; for (l = 0; l < DDIR_RWDIR_CNT; l++) { if (!dst->unified_rw_rep) { - sum_stat(&dst->clat_stat[l], &src->clat_stat[l], nr); - sum_stat(&dst->slat_stat[l], &src->slat_stat[l], nr); - sum_stat(&dst->lat_stat[l], &src->lat_stat[l], nr); - sum_stat(&dst->bw_stat[l], &src->bw_stat[l], nr); + sum_stat(&dst->clat_stat[l], &src->clat_stat[l], first); + sum_stat(&dst->slat_stat[l], &src->slat_stat[l], first); + sum_stat(&dst->lat_stat[l], &src->lat_stat[l], first); + sum_stat(&dst->bw_stat[l], &src->bw_stat[l], first); dst->io_bytes[l] += src->io_bytes[l]; if (dst->runtime[l] < src->runtime[l]) dst->runtime[l] = src->runtime[l]; } else { - sum_stat(&dst->clat_stat[0], &src->clat_stat[l], nr); - sum_stat(&dst->slat_stat[0], &src->slat_stat[l], nr); - sum_stat(&dst->lat_stat[0], &src->lat_stat[l], nr); - sum_stat(&dst->bw_stat[0], &src->bw_stat[l], nr); + sum_stat(&dst->clat_stat[0], &src->clat_stat[l], first); + sum_stat(&dst->slat_stat[0], &src->slat_stat[l], first); + sum_stat(&dst->lat_stat[0], &src->lat_stat[l], first); + sum_stat(&dst->bw_stat[0], &src->bw_stat[l], first); dst->io_bytes[0] += src->io_bytes[l]; if (dst->runtime[0] < src->runtime[l]) dst->runtime[0] = src->runtime[l]; + + /* + * We're summing to the same destination, so override + * 'first' after the first iteration of the loop + */ + first = false; } } @@ -1531,7 +1538,7 @@ void __show_run_stats(void) for (k = 0; k < ts->nr_block_infos; k++) ts->block_infos[k] = td->ts.block_infos[k]; - sum_thread_stats(ts, &td->ts, idx); + sum_thread_stats(ts, &td->ts, idx == 1); } for (i = 0; i < nr_ts; i++) { diff --git a/stat.h b/stat.h index 0fc5533f..33afd9b8 100644 --- a/stat.h +++ b/stat.h @@ -256,7 +256,7 @@ extern void __show_run_stats(void); extern void __show_running_run_stats(void); extern void show_running_run_stats(void); extern void check_for_running_stats(void); -extern void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, int nr); +extern void sum_thread_stats(struct thread_stat *dst, struct thread_stat *src, bool first); extern void sum_group_stats(struct group_run_stats *dst, struct group_run_stats *src); extern void init_thread_stat(struct thread_stat *ts); extern void init_group_run_stat(struct group_run_stats *gs); diff --git a/workqueue.c b/workqueue.c index 27570b2a..8d43b090 100644 --- a/workqueue.c +++ b/workqueue.c @@ -363,7 +363,7 @@ static void shutdown_worker(struct submit_worker *sw, unsigned int *sum_cnt) pthread_join(sw->thread, NULL); (*sum_cnt)++; - sum_thread_stats(&parent->ts, &sw->td.ts, *sum_cnt); + sum_thread_stats(&parent->ts, &sw->td.ts, *sum_cnt == 1); free_worker(sw); }