static struct itimerval itimer;
static struct list_head disk_list = LIST_HEAD_INIT(disk_list);
+static dev_t last_dev;
/*
- * Cheasy number->string conversion, complete with carry rounding error.
+ * Cheesy number->string conversion, complete with carry rounding error.
*/
static char *num2str(unsigned long num, int maxlen, int base)
{
dev_t dev;
char *p;
- if (!td->do_disk_util || (td->io_ops->flags & (FIO_NETIO | FIO_NULLIO)))
+ if (!td->do_disk_util || (td->io_ops->flags & FIO_DISKLESSIO))
return;
/*
if (disk_util_exists(dev))
return;
+
+ /*
+ * for an fs without a device, we will repeatedly stat through
+ * sysfs which can take oodles of time for thousands of files. so
+ * cache the last lookup and compare with that before going through
+ * everything again.
+ */
+ if (dev == last_dev)
+ return;
+
+ last_dev = dev;
sprintf(foo, "/sys/block");
if (!find_block_dir(dev, foo))
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);
else
fprintf(f_out, "%s: (groupid=%d): err=%2d (%s): pid=%d\n",td->name, td->groupid, td->error, td->verror, td->pid);
- show_ddir_status(td, rs, td->ddir);
- if (td->io_bytes[td->ddir ^ 1])
- show_ddir_status(td, rs, td->ddir ^ 1);
+ if (td_read(td))
+ show_ddir_status(td, rs, DDIR_READ);
+ if (td_write(td))
+ show_ddir_status(td, rs, DDIR_WRITE);
runtime = mtime_since(&td->epoch, &td->end_time);
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;
}
- fprintf(f_out, " lat (msec): 2=%3.1f%%, 4=%3.1f%%, 8=%3.1f%%, 16=%3.1f%%, 32=%3.1f%%, 64=%3.1f%%, 128=%3.1f%%\n", io_u_lat[0], io_u_lat[1], io_u_lat[2], io_u_lat[3], io_u_lat[4], io_u_lat[5], io_u_lat[6]);
- fprintf(f_out, " lat (msec): 256=%3.1f%%, 512=%3.1f%%, 1024=%3.1f%%, >=2048=%3.1f%%\n", io_u_lat[7], io_u_lat[8], io_u_lat[9], io_u_lat[10]);
+ fprintf(f_out, " lat (msec): 2=%3.1f%%, 4=%3.1f%%, 10=%3.1f%%, 20=%3.1f%%, 50=%3.1f%%, 100=%3.1f%%\n", io_u_lat[0], io_u_lat[1], io_u_lat[2], io_u_lat[3], io_u_lat[4], io_u_lat[5]);
+ fprintf(f_out, " lat (msec): 250=%3.1f%%, 500=%3.1f%%, 750=%3.1f%%, 1000=%3.1f%%, >=2000=%3.1f%%\n", io_u_lat[6], io_u_lat[7], io_u_lat[8], io_u_lat[9], io_u_lat[10]);
if (td->description)
fprintf(f_out, "%s\n", td->description);
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;