Move getrusage() out of thread_stat
authorJens Axboe <axboe@kernel.dk>
Mon, 3 Oct 2011 10:14:19 +0000 (12:14 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 3 Oct 2011 10:14:19 +0000 (12:14 +0200)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fio.c
fio.h
stat.c

diff --git a/fio.c b/fio.c
index baa17cf091823610ec691b1f32046ad9bca9ee60..765c5179758597d451d2df4ecde6df16c518742f 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1169,7 +1169,7 @@ static void *thread_main(void *data)
        }
 
        fio_gettime(&td->epoch, NULL);
        }
 
        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)) {
 
        clear_state = 0;
        while (keep_running(td)) {
diff --git a/fio.h b/fio.h
index 12b3e3d8583c8a7682a418212ec36007ef24615e..d540645ff74b5a400a358b8879e8a5ab66e19163 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -192,8 +192,6 @@ struct thread_stat {
        /*
         * fio system usage accounting
         */
        /*
         * fio system usage accounting
         */
-       struct rusage ru_start;
-       struct rusage ru_end;
        uint64_t usr_time;
        uint64_t sys_time;
        uint64_t ctx;
        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];
 
        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;
        struct fio_file **files;
        unsigned int files_size;
        unsigned int files_index;
diff --git a/stat.c b/stat.c
index 17245d9ec92dedfd6d6bdc5df3470f92899629f5..4bae5767c852cae4fb254a23f367c8a88463998e 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -14,18 +14,18 @@ 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);
-
-       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));
 }
 
 /*
 }
 
 /*