From b2560f3ca4677e2908fc4111f4d04fae5df3b229 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 6 Mar 2007 12:43:03 +0100 Subject: [PATCH] One step closer to group reporting Signed-off-by: Jens Axboe --- fio.c | 20 ++++++++++---------- fio.h | 26 ++++++++++++++++---------- init.c | 24 ++++++++++++++++++------ io_u.c | 6 +++--- stat.c | 28 ++++++++++++++-------------- 5 files changed, 61 insertions(+), 43 deletions(-) diff --git a/fio.c b/fio.c index f183eeb5..ab84b60a 100644 --- 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; - 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; @@ -751,15 +751,15 @@ static void *thread_main(void *data) 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); - 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) - 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); @@ -796,12 +796,12 @@ static void *thread_main(void *data) 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) { diff --git a/fio.h b/fio.h index daf316b4..d1d02b03 100644 --- a/fio.h +++ b/fio.h @@ -248,6 +248,12 @@ struct fio_file { 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; @@ -271,13 +277,14 @@ struct thread_stat { 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. @@ -292,7 +299,8 @@ struct thread_data { 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; @@ -361,6 +369,7 @@ struct thread_data { unsigned int rwmixwrite; unsigned int nice; unsigned int file_service_type; + unsigned int group_reporting; 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; - 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; diff --git a/init.c b/init.c index af7f2c8f..6dcd8017 100644 --- 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), }, + { + .name = "group_reporting", + .type = FIO_OPT_STR_SET, + .off1 = td_var_offset(group_reporting), + .help = "Do reporting on a per-group basis", + }, { .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; + /* + * 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) @@ -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); - 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++; @@ -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) { - 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) - setup_log(&td->ts.bw_log); + setup_log(&td->ts->bw_log); if (!td->name) td->name = strdup(jobname); diff --git a/io_u.c b/io_u.c index 698952c7..5b5802c1 100644 --- a/io_u.c +++ b/io_u.c @@ -286,8 +286,8 @@ static void io_u_mark_depth(struct thread_data *td) 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) @@ -321,7 +321,7 @@ static void io_u_mark_latency(struct thread_data *td, unsigned long msec) break; } - td->io_u_lat[index]++; + td->ts->io_u_lat[index]++; } /* diff --git a/stat.c b/stat.c index f71c5f03..576e5d2f 100644 --- a/stat.c +++ b/stat.c @@ -322,7 +322,7 @@ void disk_util_timer_arm(void) 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); @@ -434,7 +434,7 @@ static void show_ddir_status(struct thread_data *td, struct group_run_stats *rs, 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); @@ -475,20 +475,20 @@ static void show_thread_status(struct thread_data *td, 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; } - 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++) { - 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; } @@ -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++) { - 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; } @@ -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) { - struct thread_stat *ts = &td->ts; + struct thread_stat *ts = td->ts; 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]); - 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; } - 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) @@ -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) { - struct thread_stat *ts = &td->ts; + struct thread_stat *ts = td->ts; 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) { - struct thread_stat *ts = &td->ts; + struct thread_stat *ts = td->ts; 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) { - 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; -- 2.25.1