From f0505a1457d848e25e59f0d4373a066c2cef5de0 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 3 Oct 2011 12:12:03 +0200 Subject: [PATCH] Move stat_io_bytes/time to thread_data Anything that isn't needed to sum/show thread stats should not be in struct thread_stat. Signed-off-by: Jens Axboe --- fio.c | 10 ++++------ fio.h | 6 +++--- stat.c | 9 ++++----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/fio.c b/fio.c index 762303e5..baa17cf0 100644 --- a/fio.c +++ b/fio.c @@ -974,7 +974,7 @@ static int keep_running(struct thread_data *td) static void reset_io_counters(struct thread_data *td) { - td->ts.stat_io_bytes[0] = td->ts.stat_io_bytes[1] = 0; + td->stat_io_bytes[0] = td->stat_io_bytes[1] = 0; td->this_io_bytes[0] = td->this_io_bytes[1] = 0; td->zone_bytes = 0; td->rate_bytes[0] = td->rate_bytes[1] = 0; @@ -1174,14 +1174,12 @@ static void *thread_main(void *data) clear_state = 0; while (keep_running(td)) { fio_gettime(&td->start, NULL); - memcpy(&td->ts.stat_sample_time[0], &td->start, - sizeof(td->start)); - memcpy(&td->ts.stat_sample_time[1], &td->start, - sizeof(td->start)); + memcpy(&td->stat_sample_time[0], &td->start, sizeof(td->start)); + memcpy(&td->stat_sample_time[1], &td->start, sizeof(td->start)); memcpy(&td->tv_cache, &td->start, sizeof(td->start)); if (td->o.ratemin[0] || td->o.ratemin[1]) - memcpy(&td->lastrate, &td->ts.stat_sample_time, + memcpy(&td->lastrate, &td->stat_sample_time, sizeof(td->lastrate)); if (clear_state) diff --git a/fio.h b/fio.h index b0307df9..12b3e3d8 100644 --- a/fio.h +++ b/fio.h @@ -189,9 +189,6 @@ struct thread_stat { struct io_stat lat_stat[2]; /* total latency */ struct io_stat bw_stat[2]; /* bandwidth stats */ - uint64_t stat_io_bytes[2]; - struct timeval stat_sample_time[2]; - /* * fio system usage accounting */ @@ -432,6 +429,9 @@ struct thread_data { struct io_log *lat_log; struct io_log *bw_log; + uint64_t stat_io_bytes[2]; + struct timeval stat_sample_time[2]; + struct fio_file **files; unsigned int files_size; unsigned int files_index; diff --git a/stat.c b/stat.c index 998e414c..17245d9e 100644 --- a/stat.c +++ b/stat.c @@ -763,7 +763,6 @@ void show_run_stats(void) sum_stat(&ts->lat_stat[l], &td->ts.lat_stat[l], idx); sum_stat(&ts->bw_stat[l], &td->ts.bw_stat[l], idx); - ts->stat_io_bytes[l] += td->ts.stat_io_bytes[l]; ts->io_bytes[l] += td->ts.io_bytes[l]; if (ts->runtime[l] < td->ts.runtime[l]) @@ -998,17 +997,17 @@ void add_bw_sample(struct thread_data *td, enum fio_ddir ddir, unsigned int bs, if (!ddir_rw(ddir)) return; - spent = mtime_since(&ts->stat_sample_time[ddir], t); + spent = mtime_since(&td->stat_sample_time[ddir], t); if (spent < td->o.bw_avg_time) return; - rate = (td->this_io_bytes[ddir] - ts->stat_io_bytes[ddir]) * + rate = (td->this_io_bytes[ddir] - td->stat_io_bytes[ddir]) * 1000 / spent / 1024; add_stat_sample(&ts->bw_stat[ddir], rate); if (td->bw_log) add_log_sample(td, td->bw_log, rate, ddir, bs); - fio_gettime(&ts->stat_sample_time[ddir], NULL); - ts->stat_io_bytes[ddir] = td->this_io_bytes[ddir]; + fio_gettime(&td->stat_sample_time[ddir], NULL); + td->stat_io_bytes[ddir] = td->this_io_bytes[ddir]; } -- 2.25.1