X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=gettime.c;h=b1431f329bec2e3ef9e32439035d896e9f8545ca;hp=80eeaf14bcbb75293a1621382eaa8d765fe2d015;hb=be4ecfdf6c8daa75c4df8ac875c9a87da80d81a0;hpb=43c129b4ff85a7f7f7e0929f9dd73e756e37a2e3 diff --git a/gettime.c b/gettime.c index 80eeaf14..b1431f32 100644 --- a/gettime.c +++ b/gettime.c @@ -6,6 +6,7 @@ #include #include "fio.h" +#include "smalloc.h" #include "hash.h" @@ -13,6 +14,10 @@ static int clock_gettime_works; static struct timeval last_tv; static int last_tv_valid; +static struct timeval *fio_tv; +int fio_gtod_offload = 0; +int fio_gtod_cpu = -1; + #ifdef FIO_DEBUG_TIME #define HASH_BITS 8 @@ -116,7 +121,10 @@ void fio_gettime(struct timeval *tp, void fio_unused *caller) gtod_log_caller(caller); #endif - if (!clock_gettime_works) { + if (fio_tv) { + memcpy(tp, fio_tv, sizeof(*tp)); + return; + } else if (!clock_gettime_works) { gtod: gettimeofday(tp, NULL); } else { @@ -145,3 +153,14 @@ gtod: last_tv_valid = 1; memcpy(&last_tv, tp, sizeof(*tp)); } + +void fio_gtod_init(void) +{ + fio_tv = smalloc(sizeof(struct timeval)); + assert(fio_tv); +} + +void fio_gtod_update(void) +{ + gettimeofday(fio_tv, NULL); +}