One step closer to group reporting
authorJens Axboe <jens.axboe@oracle.com>
Tue, 6 Mar 2007 11:43:03 +0000 (12:43 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 6 Mar 2007 11:43:03 +0000 (12:43 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.c
fio.h
init.c
io_u.c
stat.c

diff --git a/fio.c b/fio.c
index f183eeb5f3ea8da9667068c718a1780171498202..ab84b60a59ca77ace2e9984b4353b530a569ed8c 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -661,7 +661,7 @@ static void clear_io_state(struct thread_data *td)
        struct fio_file *f;
        int i;
 
        struct fio_file *f;
        int i;
 
-       td->ts.stat_io_bytes[0] = td->ts.stat_io_bytes[1] = 0;
+       td->ts->stat_io_bytes[0] = td->ts->stat_io_bytes[1] = 0;
        td->this_io_bytes[0] = td->this_io_bytes[1] = 0;
        td->zone_bytes = 0;
 
        td->this_io_bytes[0] = td->this_io_bytes[1] = 0;
        td->zone_bytes = 0;
 
@@ -751,15 +751,15 @@ static void *thread_main(void *data)
 
        fio_gettime(&td->epoch, NULL);
        memcpy(&td->timeout_end, &td->epoch, sizeof(td->epoch));
 
        fio_gettime(&td->epoch, NULL);
        memcpy(&td->timeout_end, &td->epoch, sizeof(td->epoch));
-       getrusage(RUSAGE_SELF, &td->ts.ru_start);
+       getrusage(RUSAGE_SELF, &td->ts->ru_start);
 
        runtime[0] = runtime[1] = 0;
        while (td->loops--) {
                fio_gettime(&td->start, NULL);
 
        runtime[0] = runtime[1] = 0;
        while (td->loops--) {
                fio_gettime(&td->start, NULL);
-               memcpy(&td->ts.stat_sample_time, &td->start, sizeof(td->start));
+               memcpy(&td->ts->stat_sample_time, &td->start, sizeof(td->start));
 
                if (td->ratemin)
 
                if (td->ratemin)
-                       memcpy(&td->lastrate, &td->ts.stat_sample_time, sizeof(td->lastrate));
+                       memcpy(&td->lastrate, &td->ts->stat_sample_time, sizeof(td->lastrate));
 
                clear_io_state(td);
                prune_io_piece_log(td);
 
                clear_io_state(td);
                prune_io_piece_log(td);
@@ -796,12 +796,12 @@ static void *thread_main(void *data)
        td->runtime[0] = runtime[0] / 1000;
        td->runtime[1] = runtime[1] / 1000;
 
        td->runtime[0] = runtime[0] / 1000;
        td->runtime[1] = runtime[1] / 1000;
 
-       if (td->ts.bw_log)
-               finish_log(td, td->ts.bw_log, "bw");
-       if (td->ts.slat_log)
-               finish_log(td, td->ts.slat_log, "slat");
-       if (td->ts.clat_log)
-               finish_log(td, td->ts.clat_log, "clat");
+       if (td->ts->bw_log)
+               finish_log(td, td->ts->bw_log, "bw");
+       if (td->ts->slat_log)
+               finish_log(td, td->ts->slat_log, "slat");
+       if (td->ts->clat_log)
+               finish_log(td, td->ts->clat_log, "clat");
        if (td->write_iolog_file)
                write_iolog_close(td);
        if (td->exec_postrun) {
        if (td->write_iolog_file)
                write_iolog_close(td);
        if (td->exec_postrun) {
diff --git a/fio.h b/fio.h
index daf316b4fb917a41f11ff91f72366d2a8c4f7ff1..d1d02b038015c247e7df06f05246db7e7fdf77ed 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -248,6 +248,12 @@ struct fio_file {
        unsigned int unlink;
 };
 
        unsigned int unlink;
 };
 
+/*
+ * How many depth levels to log
+ */
+#define FIO_IO_U_MAP_NR        8
+#define FIO_IO_U_LAT_NR 12
+
 struct thread_stat {
        struct io_log *slat_log;
        struct io_log *clat_log;
 struct thread_stat {
        struct io_log *slat_log;
        struct io_log *clat_log;
@@ -271,13 +277,14 @@ struct thread_stat {
        unsigned long usr_time;
        unsigned long sys_time;
        unsigned long ctx;
        unsigned long usr_time;
        unsigned long sys_time;
        unsigned long ctx;
-};
 
 
-/*
- * How many depth levels to log
- */
-#define FIO_IO_U_MAP_NR        8
-#define FIO_IO_U_LAT_NR 12
+       /*
+        * IO depth and latency stats
+        */
+       unsigned int io_u_map[FIO_IO_U_MAP_NR];
+       unsigned int io_u_lat[FIO_IO_U_LAT_NR];
+       unsigned long total_io_u;
+};
 
 /*
  * This describes a single thread/process executing a fio job.
 
 /*
  * This describes a single thread/process executing a fio job.
@@ -292,7 +299,8 @@ struct thread_data {
        pthread_t thread;
        int thread_number;
        int groupid;
        pthread_t thread;
        int thread_number;
        int groupid;
-       struct thread_stat ts;
+       struct thread_stat *ts;
+       struct thread_stat __ts;
        enum fio_filetype filetype;
        struct fio_file *files;
        unsigned int nr_files;
        enum fio_filetype filetype;
        struct fio_file *files;
        unsigned int nr_files;
@@ -361,6 +369,7 @@ struct thread_data {
        unsigned int rwmixwrite;
        unsigned int nice;
        unsigned int file_service_type;
        unsigned int rwmixwrite;
        unsigned int nice;
        unsigned int file_service_type;
+       unsigned int group_reporting;
 
        char *read_iolog_file;
        char *write_iolog_file;
 
        char *read_iolog_file;
        char *write_iolog_file;
@@ -385,9 +394,6 @@ struct thread_data {
         * Current IO depth and list of free and busy io_u's.
         */
        unsigned int cur_depth;
         * Current IO depth and list of free and busy io_u's.
         */
        unsigned int cur_depth;
-       unsigned int io_u_map[FIO_IO_U_MAP_NR];
-       unsigned int io_u_lat[FIO_IO_U_LAT_NR];
-       unsigned long total_io_u;
        struct list_head io_u_freelist;
        struct list_head io_u_busylist;
        struct list_head io_u_requeues;
        struct list_head io_u_freelist;
        struct list_head io_u_busylist;
        struct list_head io_u_requeues;
diff --git a/init.c b/init.c
index af7f2c8f14ec1cce773e3b3cc94c88f07382377c..6dcd8017a1741e708f0b1234667d38f7c64ed0b1 100644 (file)
--- a/init.c
+++ b/init.c
@@ -530,6 +530,12 @@ static struct fio_option options[] = {
                .help   = "When using hugepages, specify size of each page",
                .def    = __stringify(FIO_HUGE_PAGE),
        },
                .help   = "When using hugepages, specify size of each page",
                .def    = __stringify(FIO_HUGE_PAGE),
        },
+       {
+               .name   = "group_reporting",
+               .type   = FIO_OPT_STR_SET,
+               .off1   = td_var_offset(group_reporting),
+               .help   = "Do reporting on a per-group basis",
+       },
        {
                .name = NULL,
        },
        {
                .name = NULL,
        },
@@ -778,6 +784,12 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (td == &def_thread)
                return 0;
 
        if (td == &def_thread)
                return 0;
 
+       /*
+        * this will later be shared between thread for group reporting
+        */
+       td->ts = &td->__ts;
+       memset(td->ts, 0, sizeof(*td->ts));
+
        assert(td->io_ops);
 
        if (td->odirect)
        assert(td->io_ops);
 
        if (td->odirect)
@@ -844,9 +856,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                
        fio_sem_init(&td->mutex, 0);
 
                
        fio_sem_init(&td->mutex, 0);
 
-       td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX;
-       td->ts.slat_stat[0].min_val = td->ts.slat_stat[1].min_val = ULONG_MAX;
-       td->ts.bw_stat[0].min_val = td->ts.bw_stat[1].min_val = ULONG_MAX;
+       td->ts->clat_stat[0].min_val = td->ts->clat_stat[1].min_val = ULONG_MAX;
+       td->ts->slat_stat[0].min_val = td->ts->slat_stat[1].min_val = ULONG_MAX;
+       td->ts->bw_stat[0].min_val = td->ts->bw_stat[1].min_val = ULONG_MAX;
 
        if (td->stonewall && td->thread_number > 1)
                groupid++;
 
        if (td->stonewall && td->thread_number > 1)
                groupid++;
@@ -857,11 +869,11 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                goto err;
 
        if (td->write_lat_log) {
                goto err;
 
        if (td->write_lat_log) {
-               setup_log(&td->ts.slat_log);
-               setup_log(&td->ts.clat_log);
+               setup_log(&td->ts->slat_log);
+               setup_log(&td->ts->clat_log);
        }
        if (td->write_bw_log)
        }
        if (td->write_bw_log)
-               setup_log(&td->ts.bw_log);
+               setup_log(&td->ts->bw_log);
 
        if (!td->name)
                td->name = strdup(jobname);
 
        if (!td->name)
                td->name = strdup(jobname);
diff --git a/io_u.c b/io_u.c
index 698952c7eb964bccb1c01feb2af1357108b8c0b8..5b5802c15ecb9041db66ec5ba755f84c98198f9c 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -286,8 +286,8 @@ static void io_u_mark_depth(struct thread_data *td)
                break;
        }
 
                break;
        }
 
-       td->io_u_map[index]++;
-       td->total_io_u++;
+       td->ts->io_u_map[index]++;
+       td->ts->total_io_u++;
 }
 
 static void io_u_mark_latency(struct thread_data *td, unsigned long msec)
 }
 
 static void io_u_mark_latency(struct thread_data *td, unsigned long msec)
@@ -321,7 +321,7 @@ static void io_u_mark_latency(struct thread_data *td, unsigned long msec)
                break;
        }
 
                break;
        }
 
-       td->io_u_lat[index]++;
+       td->ts->io_u_lat[index]++;
 }
 
 /*
 }
 
 /*
diff --git a/stat.c b/stat.c
index f71c5f03a574f4a7d3f1af222527b4ec7a78f7a9..576e5d2f514d9fb68a84006606a2370ee6c2d982 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -322,7 +322,7 @@ void disk_util_timer_arm(void)
 
 void update_rusage_stat(struct thread_data *td)
 {
 
 void update_rusage_stat(struct thread_data *td)
 {
-       struct thread_stat *ts = &td->ts;
+       struct thread_stat *ts = td->ts;
 
        getrusage(RUSAGE_SELF, &ts->ru_end);
 
 
        getrusage(RUSAGE_SELF, &ts->ru_end);
 
@@ -434,7 +434,7 @@ static void show_ddir_status(struct thread_data *td, struct group_run_stats *rs,
        free(io_p);
        free(bw_p);
 
        free(io_p);
        free(bw_p);
 
-       ts = &td->ts;
+       ts = td->ts;
        if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
                fprintf(f_out, "    slat (msec): min=%5lu, max=%5lu, avg=%5.02f, stdev=%5.02f\n", min, max, mean, dev);
 
        if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
                fprintf(f_out, "    slat (msec): min=%5lu, max=%5lu, avg=%5.02f, stdev=%5.02f\n", min, max, mean, dev);
 
@@ -475,20 +475,20 @@ static void show_thread_status(struct thread_data *td,
        if (runtime) {
                double runt = (double) runtime;
 
        if (runtime) {
                double runt = (double) runtime;
 
-               usr_cpu = (double) td->ts.usr_time * 100 / runt;
-               sys_cpu = (double) td->ts.sys_time * 100 / runt;
+               usr_cpu = (double) td->ts->usr_time * 100 / runt;
+               sys_cpu = (double) td->ts->sys_time * 100 / runt;
        } else {
                usr_cpu = 0;
                sys_cpu = 0;
        }
 
        } else {
                usr_cpu = 0;
                sys_cpu = 0;
        }
 
-       fprintf(f_out, "  cpu          : usr=%3.2f%%, sys=%3.2f%%, ctx=%lu\n", usr_cpu, sys_cpu, td->ts.ctx);
+       fprintf(f_out, "  cpu          : usr=%3.2f%%, sys=%3.2f%%, ctx=%lu\n", usr_cpu, sys_cpu, td->ts->ctx);
 
        /*
         * Do depth distribution calculations
         */
        for (i = 0; i < FIO_IO_U_MAP_NR; i++) {
 
        /*
         * Do depth distribution calculations
         */
        for (i = 0; i < FIO_IO_U_MAP_NR; i++) {
-               io_u_dist[i] = (double) td->io_u_map[i] / (double) td->total_io_u;
+               io_u_dist[i] = (double) td->ts->io_u_map[i] / (double) td->ts->total_io_u;
                io_u_dist[i] *= 100.0;
        }
 
                io_u_dist[i] *= 100.0;
        }
 
@@ -498,7 +498,7 @@ static void show_thread_status(struct thread_data *td,
         * Do latency distribution calculations
         */
        for (i = 0; i < FIO_IO_U_LAT_NR; i++) {
         * Do latency distribution calculations
         */
        for (i = 0; i < FIO_IO_U_LAT_NR; i++) {
-               io_u_lat[i] = (double) td->io_u_lat[i] / (double) td->total_io_u;
+               io_u_lat[i] = (double) td->ts->io_u_lat[i] / (double) td->ts->total_io_u;
                io_u_lat[i] *= 100.0;
        }
 
                io_u_lat[i] *= 100.0;
        }
 
@@ -512,7 +512,7 @@ static void show_thread_status(struct thread_data *td,
 static void show_ddir_status_terse(struct thread_data *td,
                                   struct group_run_stats *rs, int ddir)
 {
 static void show_ddir_status_terse(struct thread_data *td,
                                   struct group_run_stats *rs, int ddir)
 {
-       struct thread_stat *ts = &td->ts;
+       struct thread_stat *ts = td->ts;
        unsigned long min, max;
        unsigned long long bw;
        double mean, dev;
        unsigned long min, max;
        unsigned long long bw;
        double mean, dev;
@@ -557,14 +557,14 @@ static void show_thread_status_terse(struct thread_data *td,
        if (td->runtime[0] + td->runtime[1]) {
                double runt = (double) (td->runtime[0] + td->runtime[1]);
 
        if (td->runtime[0] + td->runtime[1]) {
                double runt = (double) (td->runtime[0] + td->runtime[1]);
 
-               usr_cpu = (double) td->ts.usr_time * 100 / runt;
-               sys_cpu = (double) td->ts.sys_time * 100 / runt;
+               usr_cpu = (double) td->ts->usr_time * 100 / runt;
+               sys_cpu = (double) td->ts->sys_time * 100 / runt;
        } else {
                usr_cpu = 0;
                sys_cpu = 0;
        }
 
        } else {
                usr_cpu = 0;
                sys_cpu = 0;
        }
 
-       fprintf(f_out, ",%f%%,%f%%,%lu\n", usr_cpu, sys_cpu, td->ts.ctx);
+       fprintf(f_out, ",%f%%,%f%%,%lu\n", usr_cpu, sys_cpu, td->ts->ctx);
 }
 
 void show_run_stats(void)
 }
 
 void show_run_stats(void)
@@ -700,7 +700,7 @@ void add_agg_sample(unsigned long val, enum fio_ddir ddir)
 void add_clat_sample(struct thread_data *td, enum fio_ddir ddir,
                     unsigned long msec)
 {
 void add_clat_sample(struct thread_data *td, enum fio_ddir ddir,
                     unsigned long msec)
 {
-       struct thread_stat *ts = &td->ts;
+       struct thread_stat *ts = td->ts;
 
        add_stat_sample(&ts->clat_stat[ddir], msec);
 
 
        add_stat_sample(&ts->clat_stat[ddir], msec);
 
@@ -711,7 +711,7 @@ void add_clat_sample(struct thread_data *td, enum fio_ddir ddir,
 void add_slat_sample(struct thread_data *td, enum fio_ddir ddir,
                     unsigned long msec)
 {
 void add_slat_sample(struct thread_data *td, enum fio_ddir ddir,
                     unsigned long msec)
 {
-       struct thread_stat *ts = &td->ts;
+       struct thread_stat *ts = td->ts;
 
        add_stat_sample(&ts->slat_stat[ddir], msec);
 
 
        add_stat_sample(&ts->slat_stat[ddir], msec);
 
@@ -722,7 +722,7 @@ void add_slat_sample(struct thread_data *td, enum fio_ddir ddir,
 void add_bw_sample(struct thread_data *td, enum fio_ddir ddir,
                   struct timeval *t)
 {
 void add_bw_sample(struct thread_data *td, enum fio_ddir ddir,
                   struct timeval *t)
 {
-       struct thread_stat *ts = &td->ts;
+       struct thread_stat *ts = td->ts;
        unsigned long spent = mtime_since(&ts->stat_sample_time[ddir], t);
        unsigned long rate;
 
        unsigned long spent = mtime_since(&ts->stat_sample_time[ddir], t);
        unsigned long rate;