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;
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);
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) {
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;
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.
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;
unsigned int rwmixwrite;
unsigned int nice;
unsigned int file_service_type;
+ unsigned int group_reporting;
char *read_iolog_file;
char *write_iolog_file;
* 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;
.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,
},
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)
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++;
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);
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)
break;
}
- td->io_u_lat[index]++;
+ td->ts->io_u_lat[index]++;
}
/*
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);
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 (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;
}
* 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;
}
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;
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)
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);
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);
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;