From patchwork Tue Nov 17 10:24:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonas Lahtinen X-Patchwork-Id: 7635261 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E83479F1D3 for ; Tue, 17 Nov 2015 10:24:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E1F6204E0 for ; Tue, 17 Nov 2015 10:24:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 52311201C0 for ; Tue, 17 Nov 2015 10:24:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B73306E2F4; Tue, 17 Nov 2015 02:24:21 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id ECF1B6E2F4 for ; Tue, 17 Nov 2015 02:24:20 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 17 Nov 2015 02:24:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,307,1444719600"; d="scan'208";a="852609821" Received: from jlahtine-mobl1.ger.corp.intel.com ([10.252.25.207]) by orsmga002.jf.intel.com with ESMTP; 17 Nov 2015 02:24:18 -0800 From: Joonas Lahtinen To: Intel graphics driver community testing & development Date: Tue, 17 Nov 2015 12:24:13 +0200 Message-Id: <1447755853-28217-1-git-send-email-joonas.lahtinen@linux.intel.com> X-Mailer: git-send-email 2.4.3 Cc: Thomas Wood Subject: [Intel-gfx] [PATCH i-g-t] lib/igt_core: Prefer CLOCK_MONOTONIC_RAW X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP CLOCK_MONOTONIC_RAW is not affected by NTP, so it should be THE clock used for timing execution of tests. Cc: Thomas Wood Cc: Chris Wilson Signed-off-by: Joonas Lahtinen Reviewed-by: Chris Wilson --- 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)