gettime: add support for CLOCK_MONOTONIC_RAW
authorSteven Noonan <steven@uplinklabs.net>
Fri, 1 May 2015 19:31:44 +0000 (12:31 -0700)
committerJens Axboe <axboe@fb.com>
Fri, 1 May 2015 23:19:27 +0000 (17:19 -0600)
The clock CLOCK_MONOTONIC_RAW (introduced in Linux 2.6.28) is similar to
CLOCK_MONOTONIC except that it is not subject to NTP adjustments or incremental
adjustments performed by adjtime().

Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Signed-off-by: Jens Axboe <axboe@fb.com>
configure
gettime.c

index 0b9874bfce3b51604610acb6ee61477f892ace96..3b871efa302acb522ed25f1f51da11fc838b0cb0 100755 (executable)
--- a/configure
+++ b/configure
@@ -720,6 +720,24 @@ EOF
 fi
 echo "CLOCK_MONOTONIC               $clock_monotonic"
 
+##########################################
+# CLOCK_MONOTONIC_RAW probe
+clock_monotonic_raw="no"
+if test "$clock_gettime" = "yes" ; then
+  cat > $TMPC << EOF
+#include <stdio.h>
+#include <time.h>
+int main(int argc, char **argv)
+{
+  return clock_gettime(CLOCK_MONOTONIC_RAW, NULL);
+}
+EOF
+  if compile_prog "" "$LIBS" "clock monotonic"; then
+      clock_monotonic_raw="yes"
+  fi
+fi
+echo "CLOCK_MONOTONIC_RAW           $clock_monotonic_raw"
+
 ##########################################
 # CLOCK_MONOTONIC_PRECISE probe
 clock_monotonic_precise="no"
@@ -1485,6 +1503,9 @@ fi
 if test "$clock_monotonic" = "yes" ; then
   output_sym "CONFIG_CLOCK_MONOTONIC"
 fi
+if test "$clock_monotonic_raw" = "yes" ; then
+  output_sym "CONFIG_CLOCK_MONOTONIC_RAW"
+fi
 if test "$clock_monotonic_precise" = "yes" ; then
   output_sym "CONFIG_CLOCK_MONOTONIC_PRECISE"
 fi
index 180aa5f2ed6c3893235e85b8852d5e9a6673affd..ac541113245fb49876ed2afa601894cff3ca776c 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -133,7 +133,9 @@ static void fio_init gtod_init(void)
 #ifdef CONFIG_CLOCK_GETTIME
 static int fill_clock_gettime(struct timespec *ts)
 {
-#ifdef CONFIG_CLOCK_MONOTONIC
+#if defined(CONFIG_CLOCK_MONOTONIC_RAW)
+       return clock_gettime(CLOCK_MONOTONIC_RAW, ts);
+#elif defined(CONFIG_CLOCK_MONOTONIC)
        return clock_gettime(CLOCK_MONOTONIC, ts);
 #else
        return clock_gettime(CLOCK_REALTIME, ts);