#include <sys/time.h>
#include "fio.h"
+#include "smalloc.h"
#include "hash.h"
-static int clock_gettime_works;
+static int clock_gettime_works = 0;
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
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 {
struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) {
+ if (clock_gettime(CLOCK_REALTIME, &ts) < 0) {
clock_gettime_works = 0;
goto 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);
+}