Move getrusage() out of thread_stat
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/fio.c b/fio.c
index baa17cf..765c517 100644
--- a/fio.c
+++ b/fio.c
@@ -1169,7 +1169,7 @@
}
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 12b3e3d..d540645 100644
--- a/fio.h
+++ b/fio.h
@@ -192,8 +192,6 @@
/*
* 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 @@
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 17245d9..4bae576 100644
--- a/stat.c
+++ b/stat.c
@@ -14,18 +14,18 @@
{
struct thread_stat *ts = &td->ts;
- getrusage(RUSAGE_SELF, &ts->ru_end);
+ getrusage(RUSAGE_SELF, &td->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;
+ 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(&ts->ru_start, &ts->ru_end, sizeof(ts->ru_end));
+ memcpy(&td->ru_start, &td->ru_end, sizeof(td->ru_end));
}
/*