[Intel-gfx] [PATCH i-g-t] lib/igt_core: Prefer CLOCK_MONOTONIC_RAW

Joonas Lahtinen joonas.lahtinen at linux.intel.com
Tue Nov 17 02:24:13 PST 2015


CLOCK_MONOTONIC_RAW is not affected by NTP, so it should be THE clock
used for timing execution of tests.

Cc: Thomas Wood <thomas.wood at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen at linux.intel.com>
---
 lib/igt_core.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 04a0ab2..5a5b1a9 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -341,10 +341,15 @@ static void gettime(struct timespec *ts)
 {
 	memset(ts, 0, sizeof(*ts));
 
+#ifdef CLOCK_MONOTONIC_RAW
+	if (!clock_gettime(CLOCK_MONOTONIC_RAW, ts))
+		return;
+#endif
 #ifdef CLOCK_MONOTONIC_COARSE
-	if (clock_gettime(CLOCK_MONOTONIC_COARSE, ts))
+	if (!clock_gettime(CLOCK_MONOTONIC_COARSE, ts))
+		return;
 #endif
-		clock_gettime(CLOCK_MONOTONIC, ts);
+	clock_gettime(CLOCK_MONOTONIC, ts);
 }
 
 bool __igt_fixture(void)
-- 
2.4.3



More information about the Intel-gfx mailing list