clock: ensure that we re-init if the clocksource changes from the default
authorJens Axboe <axboe@kernel.dk>
Fri, 14 Dec 2012 19:37:06 +0000 (20:37 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 14 Dec 2012 19:37:06 +0000 (20:37 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
gettime.c
gettime.h
options.c

index 1ba18e99877f3fc6cc5f07e8bd2185f8fadd93e0..9f23e3fff526e0611df0dd1c9d6dc1b62d059916 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -22,6 +22,7 @@ static int last_tv_valid;
 
 enum fio_cs fio_clock_source = FIO_PREFERRED_CLOCK_SOURCE;
 int fio_clock_source_set = 0;
+enum fio_cs fio_clock_source_inited = CS_INVAL;
 
 #ifdef FIO_DEBUG_TIME
 
@@ -262,7 +263,11 @@ static void calibrate_cpu_clock(void)
 
 void fio_clock_init(void)
 {
+       if (fio_clock_source == fio_clock_source_inited)
+               return;
+
        last_tv_valid = 0;
+       fio_clock_source_inited = fio_clock_source;
        calibrate_cpu_clock();
 
        /*
index 309ef2108a646e764b9e3e120cfecd7d8e9cf802..64651a1badb35ef2112e30cd46c69c857b9e4264 100644 (file)
--- a/gettime.h
+++ b/gettime.h
@@ -8,6 +8,7 @@ enum fio_cs {
        CS_GTOD         = 1,
        CS_CGETTIME,
        CS_CPUCLOCK,
+       CS_INVAL,
 };
 
 extern void fio_gettime(struct timeval *, void *);
index 738c78bb7daea3cfead7a2e1090b8af595f8c564..ae290edb15d4e45260c5a5d0c7b9dcd7c596a8d2 100644 (file)
--- a/options.c
+++ b/options.c
@@ -371,6 +371,7 @@ static int fio_clock_source_cb(void *data, const char *str)
 
        fio_clock_source = td->o.clocksource;
        fio_clock_source_set = 1;
+       fio_clock_init();
        return 0;
 }