From c544f6047b8b6f238a453e95e45644434887958d Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Fri, 1 May 2015 12:31:44 -0700 Subject: [PATCH] gettime: add support for CLOCK_MONOTONIC_RAW 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 Signed-off-by: Jens Axboe --- configure | 21 +++++++++++++++++++++ gettime.c | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 0b9874bf..3b871efa 100755 --- 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 +#include +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 diff --git a/gettime.c b/gettime.c index 180aa5f2..ac541113 100644 --- 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); -- 2.25.1