Clear rusage stat when resetting all stats
authorJens Axboe <axboe@fb.com>
Mon, 30 Nov 2015 21:44:06 +0000 (14:44 -0700)
committerJens Axboe <axboe@fb.com>
Mon, 30 Nov 2015 21:44:06 +0000 (14:44 -0700)
This fixes an issue with bad rusage reporting, particularly when
the runtime to ramptime ratio is low.

Signed-off-by: Jens Axboe <axboe@fb.com>
iolog.h
libfio.c
stat.c
stat.h

diff --git a/iolog.h b/iolog.h
index aa4562d489b3bb944577bcb3ec599f9703e0ead4..160c95771008e11774d5d2818b56b34abd307e89 100644 (file)
--- a/iolog.h
+++ b/iolog.h
@@ -214,7 +214,6 @@ extern void add_bw_sample(struct thread_data *, enum fio_ddir, unsigned int,
 extern void add_iops_sample(struct thread_data *, enum fio_ddir, unsigned int,
                                struct timeval *);
 extern void init_disk_util(struct thread_data *);
-extern void update_rusage_stat(struct thread_data *);
 extern void setup_log(struct io_log **, struct log_params *, const char *);
 extern void flush_log(struct io_log *, int);
 extern void free_log(struct io_log *);
index 3aa52e0a592e3537de5e6d57652b1f9f1d3997cd..6c74852c4f0fb65cdc387f369588a2bd5ed6ca31 100644 (file)
--- a/libfio.c
+++ b/libfio.c
@@ -148,6 +148,7 @@ void reset_all_stats(struct thread_data *td)
        memcpy(&td->start, &tv, sizeof(tv));
 
        lat_target_reset(td);
+       clear_rusage_stat(td);
 }
 
 void reset_fio_state(void)
diff --git a/stat.c b/stat.c
index da3ad2a22412dcadba647e7b5cee0250e6cfdec9..e5ec22374b8c2d410fdfa1e841ba93c0ad8ecd08 100644 (file)
--- a/stat.c
+++ b/stat.c
 
 struct fio_mutex *stat_mutex;
 
+void clear_rusage_stat(struct thread_data *td)
+{
+       struct thread_stat *ts = &td->ts;
+
+       fio_getrusage(&td->ru_start);
+       ts->usr_time = ts->sys_time = 0;
+       ts->ctx = 0;
+       ts->minf = ts->majf = 0;
+}
+
 void update_rusage_stat(struct thread_data *td)
 {
        struct thread_stat *ts = &td->ts;
diff --git a/stat.h b/stat.h
index e289c2e5e02934e41f21d6647d36fe071c8a12b6..028351124d11395d1af7d2f23e3bc7afaa779612 100644 (file)
--- a/stat.h
+++ b/stat.h
@@ -267,6 +267,8 @@ extern void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat);
 extern void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat);
 extern void stat_calc_dist(unsigned int *map, unsigned long total, double *io_u_dist);
 extern void reset_io_stats(struct thread_data *);
+extern void update_rusage_stat(struct thread_data *);
+extern void clear_rusage_stat(struct thread_data *);
 
 static inline int usec_to_msec(unsigned long *min, unsigned long *max,
                               double *mean, double *dev)