From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 C8902C433E2 for ; Mon, 14 Sep 2020 11:56:34 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 7BD222223F for ; Mon, 14 Sep 2020 11:56:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LENLqJ9t"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="kuCmwrQr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BD222223F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/M6fMzZNtuoqIRgt97InvcO6pHmdpnOCLQasRJCVTrI=; b=LENLqJ9tbxC5R7MPO8KjmHCOYX Anb2AiqELHEcUMn7FUR3wBrMt8elK+z+YPkwTR50fBNv1y/U4kbSOM9EMD1CDOVOGFQDw/nyIKJkg HMPymqtjnTCnTLNTCAp8AL1v0QwEtHf+5Z6HxzP5JucCnJhKRp9Wh3KArs4fNVvr4F2Lo4oEBvwkV TtcOYjJ/pL/MtbpYQdPFob+cH1tkYvBuRYVn05AZW8Wo33aLetamwfrA1BtKY9MMdxQ9A2XPRpcsX HSdKVkmdSi28SaarhyZ65C19F712hyxUCf8ze7uTv5FSKHHVKc6ZXVlYfPTSZhHXa4vDy2qCIDqb0 IWGiit2w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn4s-00080K-CQ; Mon, 14 Sep 2020 11:55:22 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn4o-0007yc-Lx for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 11:55:20 +0000 Received: by mail-pg1-x541.google.com with SMTP id j34so11349797pgi.7 for ; Mon, 14 Sep 2020 04:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oTMUwLGNRNQB4ie8SSya+jnVAbwSw8hpqt0lrhaUPZU=; b=kuCmwrQrg7GJ9HX906/sSdZbuErryyJ0Dz8Oj+NGbspBGEYAznqdQWVNoTE8TLZLH0 LuVLq2yO5Nk7H0eV+WdsjLsaNVOTQA3NNMYVFaUDJvMTik77DB/mWAsrYZyn96N/RvOL 97A7M+Y5Iuf5kKiFE36DrcKO0zB8g/ThDLYh3DlkkzANowb1UvV9g4ZASIEDVcQ7+O4n 3B2qz+E/JdDK+66qcmmo3+q/BWRCVwF7spBQwZW+sPdR0yHRx9cwrdc4AO3kHjr+MCZ4 tKsrlEHOIi31ZJ2NuIRE/A8kTzIBs/PE2ct0OpmbJ9wAWbkII6g/0c6ShMt2WSge4JlB 7pzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oTMUwLGNRNQB4ie8SSya+jnVAbwSw8hpqt0lrhaUPZU=; b=C20+oiN+HsBF9dIglsAEB6KAz+bW16Zq9ThCRYgGO32j9lAzz/LzxRKZc4hLdKPVk3 qQDGucC44yQ0hPjDbV5KtaYeTxWnixia4EjUZX0Mt4F/gf6MB/cJ945+ScNk4aHmkBcF jLY5Zu1PcxHiUdC/NRad33GOAMMWYPauISnXVNqCd4ixBkpxWzLT02SiOdvR0WY6PDGt FIQqzNSZIaef1DnC6B8qhuFDe4mEtJWxCd5g6FMKiOrlh/+bma4za19Ie72KMN9neqm/ IpYbzGsN4JVaFYW9ImGOUS+2Y4ks8aQRS0sKeQOcigvj6SnMZxD5qjX5h7F1wkpiCrcb 3BVg== X-Gm-Message-State: AOAM531LLjAkALwOu9LqLBwyyUMJeDRyMgfxPKp0kC5EYfOSZFGcfrFm QvUzo0fxixN2ZA+SJBVXumzEIw== X-Google-Smtp-Source: ABdhPJwMivTpJYi6MvYsaIi8RtkLmeWPRGs92dGue7CU8k3cf5rOcu1bj0SIUEFoRHy99vDQn47Vgg== X-Received: by 2002:a17:902:ac83:b029:d1:920c:c022 with SMTP id h3-20020a170902ac83b02900d1920cc022mr14302606plr.38.1600084516188; Mon, 14 Sep 2020 04:55:16 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id v13sm9068714pjr.12.2020.09.14.04.55.14 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Sep 2020 04:55:15 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Will Deacon , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Mathieu Poirier , Adrian Hunter , Kemeng Shi , Ian Rogers , Remi Bernon , Nick Gasson , Stephane Eranian , Andi Kleen , Steve MacLean , "Gustavo A. R. Silva" , Zou Wei , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 3/6] perf tsc: Calculate timestamp with cap_user_time_short Date: Mon, 14 Sep 2020 19:53:08 +0800 Message-Id: <20200914115311.2201-4-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914115311.2201-1-leo.yan@linaro.org> References: <20200914115311.2201-1-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_075518_764449_79EA6660 X-CRM114-Status: GOOD ( 16.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leo Yan MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The perf mmap'ed buffer contains the flag 'cap_user_time_short' and two extra fields 'time_cycles' and 'time_mask', perf tool needs to know them for handling the counter wrapping case. This patch is to reads out the relevant parameters from the head of the first mmap'ed page and stores into the structure 'perf_tsc_conversion', if the flag 'cap_user_time_short' has been set, it will firstly calibrate cycle value for timestamp calculation. Signed-off-by: Leo Yan --- tools/perf/util/tsc.c | 12 +++++++++--- tools/perf/util/tsc.h | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c index 9e3f04ddddf8..c0ca40204649 100644 --- a/tools/perf/util/tsc.c +++ b/tools/perf/util/tsc.c @@ -28,6 +28,10 @@ u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc) { u64 quot, rem; + if (tc->cap_user_time_short) + cyc = tc->time_cycles + + ((cyc - tc->time_cycles) & tc->time_mask); + quot = cyc >> tc->time_shift; rem = cyc & (((u64)1 << tc->time_shift) - 1); return tc->time_zero + quot * tc->time_mult + @@ -37,7 +41,6 @@ u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc) int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, struct perf_tsc_conversion *tc) { - bool cap_user_time_zero; u32 seq; int i = 0; @@ -47,7 +50,10 @@ int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, tc->time_mult = pc->time_mult; tc->time_shift = pc->time_shift; tc->time_zero = pc->time_zero; - cap_user_time_zero = pc->cap_user_time_zero; + tc->time_cycles = pc->time_cycles; + tc->time_mask = pc->time_mask; + tc->cap_user_time_zero = pc->cap_user_time_zero; + tc->cap_user_time_short = pc->cap_user_time_short; rmb(); if (pc->lock == seq && !(seq & 1)) break; @@ -57,7 +63,7 @@ int perf_read_tsc_conversion(const struct perf_event_mmap_page *pc, } } - if (!cap_user_time_zero) + if (!tc->cap_user_time_zero) return -EOPNOTSUPP; return 0; diff --git a/tools/perf/util/tsc.h b/tools/perf/util/tsc.h index 3c5a632ee57c..72a15419f3b3 100644 --- a/tools/perf/util/tsc.h +++ b/tools/perf/util/tsc.h @@ -8,6 +8,11 @@ struct perf_tsc_conversion { u16 time_shift; u32 time_mult; u64 time_zero; + u64 time_cycles; + u64 time_mask; + + bool cap_user_time_zero; + bool cap_user_time_short; }; struct perf_event_mmap_page; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel