From patchwork Fri Dec 18 08:49:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 11981589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93CC3C4361B for ; Fri, 18 Dec 2020 08:49:59 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45AD3233F6 for ; Fri, 18 Dec 2020 08:49:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45AD3233F6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B494489209; Fri, 18 Dec 2020 08:49:58 +0000 (UTC) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1805889209; Fri, 18 Dec 2020 08:49:58 +0000 (UTC) IronPort-SDR: eDSUzrbsgsOfXFZkaL5qV7zl+9QXKY9IWapWsv6C2GOXtdrnUrYezuxzuZSVZO7slhlBe1WKxv LFouGG/VgDGA== X-IronPort-AV: E=McAfee;i="6000,8403,9838"; a="155207193" X-IronPort-AV: E=Sophos;i="5.78,430,1599548400"; d="scan'208";a="155207193" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2020 00:49:54 -0800 IronPort-SDR: NDP+K7ryO97wAaKDs8xWd9FPcyQ9934PQuh3HLsabRAcWZK7DMoWyarmIihFyeyF9vHZMlITz7 NedvtnOViRRg== X-IronPort-AV: E=Sophos;i="5.78,430,1599548400"; d="scan'208";a="340289754" Received: from mizrahid-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.214.205.41]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2020 00:49:51 -0800 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Fri, 18 Dec 2020 08:49:39 +0000 Message-Id: <20201218084939.1767210-1-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] lib/igt_perf: Request CLOCK_MONOTONIC when opening events X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin Ask for CLOCK_MONOTONIC which is more stable than the default perf clock. (Ability to select a clock has been available since kernel version 4.1.) The change should not have any significant impact on the IGT as whole apart from maybe improving the occasional jitter in tests/tools which use nanosleep(2) and use time slept together with perf reported time delta either in direct or indirect calculations. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- lib/igt_perf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/igt_perf.c b/lib/igt_perf.c index 418c1c18891c..b743859f5d29 100644 --- a/lib/igt_perf.c +++ b/lib/igt_perf.c @@ -1,12 +1,13 @@ -#include +#include #include -#include +#include #include #include -#include #include #include #include +#include +#include #include "igt_perf.h" @@ -111,6 +112,8 @@ _perf_open(uint64_t type, uint64_t config, int group, uint64_t format) attr.read_format = format; attr.config = config; + attr.use_clockid = 1; + attr.clockid = CLOCK_MONOTONIC; do { ret = perf_event_open(&attr, -1, cpu++, group, 0);