Move stat_io_bytes/time to thread_data
authorJens Axboe <axboe@kernel.dk>
Mon, 3 Oct 2011 10:12:03 +0000 (12:12 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 3 Oct 2011 10:12:03 +0000 (12:12 +0200)
Anything that isn't needed to sum/show thread stats should not be
in struct thread_stat.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
fio.c
fio.h
stat.c

diff --git a/fio.c b/fio.c
index 762303e5793447808efe36dc0553043b17d6b3af..baa17cf091823610ec691b1f32046ad9bca9ee60 100644 (file)
--- 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 b0307df9b72f33663c1517efb25c82d735c0cfb5..12b3e3d8583c8a7682a418212ec36007ef24615e 100644 (file)
--- 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 998e414c12d5c2a204e9869a194e7434eb2e9a92..17245d9ec92dedfd6d6bdc5df3470f92899629f5 100644 (file)
--- 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];
 }