From 210dd0fc66b8956065e098bb9314febe8993e849 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 30 Nov 2015 14:44:06 -0700 Subject: [PATCH] Clear rusage stat when resetting all stats This fixes an issue with bad rusage reporting, particularly when the runtime to ramptime ratio is low. Signed-off-by: Jens Axboe --- iolog.h | 1 - libfio.c | 1 + stat.c | 10 ++++++++++ stat.h | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/iolog.h b/iolog.h index aa4562d4..160c9577 100644 --- 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 *); diff --git a/libfio.c b/libfio.c index 3aa52e0a..6c74852c 100644 --- 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 da3ad2a2..e5ec2237 100644 --- a/stat.c +++ b/stat.c @@ -18,6 +18,16 @@ 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 e289c2e5..02835112 100644 --- 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) -- 2.25.1