From c8aaba193fd910f89486ba4caab0c023306fffae Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 3 Oct 2011 12:14:19 +0200 Subject: [PATCH] Move getrusage() out of thread_stat Signed-off-by: Jens Axboe --- fio.c | 2 +- fio.h | 5 +++-- stat.c | 24 ++++++++++++------------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fio.c b/fio.c index baa17cf0..765c5179 100644 --- a/fio.c +++ b/fio.c @@ -1169,7 +1169,7 @@ static void *thread_main(void *data) } fio_gettime(&td->epoch, NULL); - getrusage(RUSAGE_SELF, &td->ts.ru_start); + getrusage(RUSAGE_SELF, &td->ru_start); clear_state = 0; while (keep_running(td)) { diff --git a/fio.h b/fio.h index 12b3e3d8..d540645f 100644 --- a/fio.h +++ b/fio.h @@ -192,8 +192,6 @@ struct thread_stat { /* * fio system usage accounting */ - struct rusage ru_start; - struct rusage ru_end; uint64_t usr_time; uint64_t sys_time; uint64_t ctx; @@ -432,6 +430,9 @@ struct thread_data { uint64_t stat_io_bytes[2]; struct timeval stat_sample_time[2]; + struct rusage ru_start; + struct rusage ru_end; + struct fio_file **files; unsigned int files_size; unsigned int files_index; diff --git a/stat.c b/stat.c index 17245d9e..4bae5767 100644 --- a/stat.c +++ b/stat.c @@ -14,18 +14,18 @@ void update_rusage_stat(struct thread_data *td) { struct thread_stat *ts = &td->ts; - getrusage(RUSAGE_SELF, &ts->ru_end); - - ts->usr_time += mtime_since(&ts->ru_start.ru_utime, - &ts->ru_end.ru_utime); - ts->sys_time += mtime_since(&ts->ru_start.ru_stime, - &ts->ru_end.ru_stime); - ts->ctx += ts->ru_end.ru_nvcsw + ts->ru_end.ru_nivcsw - - (ts->ru_start.ru_nvcsw + ts->ru_start.ru_nivcsw); - ts->minf += ts->ru_end.ru_minflt - ts->ru_start.ru_minflt; - ts->majf += ts->ru_end.ru_majflt - ts->ru_start.ru_majflt; - - memcpy(&ts->ru_start, &ts->ru_end, sizeof(ts->ru_end)); + getrusage(RUSAGE_SELF, &td->ru_end); + + ts->usr_time += mtime_since(&td->ru_start.ru_utime, + &td->ru_end.ru_utime); + ts->sys_time += mtime_since(&td->ru_start.ru_stime, + &td->ru_end.ru_stime); + ts->ctx += td->ru_end.ru_nvcsw + td->ru_end.ru_nivcsw + - (td->ru_start.ru_nvcsw + td->ru_start.ru_nivcsw); + ts->minf += td->ru_end.ru_minflt - td->ru_start.ru_minflt; + ts->majf += td->ru_end.ru_majflt - td->ru_start.ru_majflt; + + memcpy(&td->ru_start, &td->ru_end, sizeof(td->ru_end)); } /* -- 2.25.1