From patchwork Mon Sep 14 11:53:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11773625 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F65C92C for ; Mon, 14 Sep 2020 11:55:21 +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 1F52921BE5 for ; Mon, 14 Sep 2020 11:55:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="FXNIogw0"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Y/dOoNMu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F52921BE5 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+patchwork-linux-arm=patchwork.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=vHa7wz9eFt4VPzUi07BenvF7l1EKo9BFv+Vzeq78wf0=; b=FXNIogw05EcG0pH5GXGC9NYGaH l4C+l4OzpfCRWLuhdbskynOiLKOuC/RJQokNajTgw6y/dLbVUhRaN0n7l1CyK665vlRURKSJXUbnD GElf8q+xc6Nv+esWaIte7/B6ojQAK+KuwMKJ3i9AjiGdtjEFHeAHAVyWNSVyRuVh3j2e0Uqpn9/EF Nk6HiPwmf5sMLfgKLOsEPhg64P/ecuCP4e5xmye0/4Gd8b1H0KHj4AWSAZD37w7VALbgGxnbivQmX 6d5HkQzZcTwq5IkiNUwuZ/PoO7M01uTpx5r/eOECvlaI/uf1mCtO/lxudTx6J5lNhVBHdo5AsOf0r azU3Polg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn4f-0007wZ-4Z; Mon, 14 Sep 2020 11:55:09 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn4c-0007vh-Hn for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 11:55:07 +0000 Received: by mail-pj1-x1042.google.com with SMTP id jw11so5253170pjb.0 for ; Mon, 14 Sep 2020 04:55:05 -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=j/6HwVpyTsA7z9Vl2wmHYe3cw1hSDvl7Zz8h5YgOZds=; b=Y/dOoNMuBgkwxcvT+hUX8k6okZ1RHHTdiQl0q20fDcjoSaNLlRt51ZcphRLhIZOjU1 e4yCaxt0y04cfM2viez0pq+o4otf9Jhyvb+2q8LgEfp9jh6Gs9tY3sfuemiZwN4J5K3J O/ZTpzBDqEZ/mB1p0Wbbm1+lk2dcqIeKAnxF+2WNylJu+1XA7h2QJbDdR7CA8IYLhYRy c7cT+vkZVmOq2eu7ibrVZ42t0mFBCt5hRJxDAudxByqnVVPFMcqFoGN9S+pYzilZzlWj AfQSG6r+NalGgXGu1BjCvVbf4g0pBFjtNyR+grZWVIx3K5tb2vC/qhj1FQ7dBNEox1Tk d3qw== 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=j/6HwVpyTsA7z9Vl2wmHYe3cw1hSDvl7Zz8h5YgOZds=; b=a2EolgbuDQlijcX+eDyBmg2WucX9kfSNmWrkWR+tpH2RB52Z4ykOUr5Btxq8L4Qd61 lzogf1qiF3wtLYuHpxqy1tMBXUcUrdtbsO+/2n5wG6ybHkCACSKmj/B98CUGMnZ6jmYS hVolLFQLudn0CZgnEUA2R8TtVfIO5dannLZv+TWrltBHpRYdUIAwUiz2BnxFke9x10P2 cNunxGhJosl8gztJi3vblJmtk4YVa/peD5/ei9zO/7FTZLMz1odMDGbtYx6T1uIEmfoJ K6iznpBe2NbOMf00R0Krvb2ccHucKwAtlmEqSBVrJEvjwKg8zls9yBZFzAEanQjRKvCm katw== X-Gm-Message-State: AOAM532ztGuWpkzvUEaiNtFnEZ6l+TiivZ3bwgBRfJ8KO5AmVPtaF2R9 h4F7UklWbNFt7LaKsd6R0LTbGA== X-Google-Smtp-Source: ABdhPJzfTHvkBJwm+0nN7MNxYKqFAfISJSyds/ZflITL2a55vk9yLwbYw105SDNqxwdZ9xxlEqYNcw== X-Received: by 2002:a17:90a:ea02:: with SMTP id w2mr13708647pjy.9.1600084504200; Mon, 14 Sep 2020 04:55:04 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id w185sm10709046pfc.36.2020.09.14.04.55.02 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Sep 2020 04:55:03 -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 1/6] perf tsc: Move out common functions from x86 Date: Mon, 14 Sep 2020 19:53:06 +0800 Message-Id: <20200914115311.2201-2-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_075506_778093_26E76B2B X-CRM114-Status: GOOD ( 19.61 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [2600:3c01:0:0:f03c:91ff:fe8a:bb03 listed in] [zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1042 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Functions perf_read_tsc_conversion() and perf_event__synth_time_conv() should work as common functions rather than x86 specific, so move these two functions out from arch/x86 folder and place them into util/tsc.c. Since the function perf_event__synth_time_conv() will be linked in util/tsc.c, remove its weak version. Signed-off-by: Leo Yan --- tools/perf/arch/x86/util/tsc.c | 73 +----------------------------- tools/perf/util/synthetic-events.c | 8 ---- tools/perf/util/tsc.c | 71 +++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 80 deletions(-) diff --git a/tools/perf/arch/x86/util/tsc.c b/tools/perf/arch/x86/util/tsc.c index 2f55afb14e1f..559365f8fe52 100644 --- a/tools/perf/arch/x86/util/tsc.c +++ b/tools/perf/arch/x86/util/tsc.c @@ -1,45 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 -#include -#include - -#include -#include - #include -#include -#include "../../../util/debug.h" -#include "../../../util/event.h" -#include "../../../util/synthetic-events.h" -#include "../../../util/tsc.h" - -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; - - while (1) { - seq = pc->lock; - rmb(); - 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; - rmb(); - if (pc->lock == seq && !(seq & 1)) - break; - if (++i > 10000) { - pr_debug("failed to get perf_event_mmap_page lock\n"); - return -EINVAL; - } - } - if (!cap_user_time_zero) - return -EOPNOTSUPP; - - return 0; -} +#include "../../../util/tsc.h" u64 rdtsc(void) { @@ -49,36 +11,3 @@ u64 rdtsc(void) return low | ((u64)high) << 32; } - -int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, - struct perf_tool *tool, - perf_event__handler_t process, - struct machine *machine) -{ - union perf_event event = { - .time_conv = { - .header = { - .type = PERF_RECORD_TIME_CONV, - .size = sizeof(struct perf_record_time_conv), - }, - }, - }; - struct perf_tsc_conversion tc; - int err; - - if (!pc) - return 0; - err = perf_read_tsc_conversion(pc, &tc); - if (err == -EOPNOTSUPP) - return 0; - if (err) - return err; - - pr_debug2("Synthesizing TSC conversion information\n"); - - event.time_conv.time_mult = tc.time_mult; - event.time_conv.time_shift = tc.time_shift; - event.time_conv.time_zero = tc.time_zero; - - return process(tool, &event, NULL, machine); -} diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c index 89b390623b63..3ca5d9399680 100644 --- a/tools/perf/util/synthetic-events.c +++ b/tools/perf/util/synthetic-events.c @@ -2006,14 +2006,6 @@ int perf_event__synthesize_stat_events(struct perf_stat_config *config, struct p return 0; } -int __weak perf_event__synth_time_conv(const struct perf_event_mmap_page *pc __maybe_unused, - struct perf_tool *tool __maybe_unused, - perf_event__handler_t process __maybe_unused, - struct machine *machine __maybe_unused) -{ - return 0; -} - extern const struct perf_header_feature_ops feat_ops[HEADER_LAST_FEATURE]; int perf_event__synthesize_features(struct perf_tool *tool, struct perf_session *session, diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c index bfa782421cbd..9e3f04ddddf8 100644 --- a/tools/perf/util/tsc.c +++ b/tools/perf/util/tsc.c @@ -1,7 +1,16 @@ // SPDX-License-Identifier: GPL-2.0 +#include + #include +#include +#include #include +#include + +#include "event.h" +#include "synthetic-events.h" +#include "debug.h" #include "tsc.h" u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc) @@ -25,6 +34,68 @@ u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc) ((rem * tc->time_mult) >> tc->time_shift); } +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; + + while (1) { + seq = pc->lock; + rmb(); + 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; + rmb(); + if (pc->lock == seq && !(seq & 1)) + break; + if (++i > 10000) { + pr_debug("failed to get perf_event_mmap_page lock\n"); + return -EINVAL; + } + } + + if (!cap_user_time_zero) + return -EOPNOTSUPP; + + return 0; +} + +int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, + struct perf_tool *tool, + perf_event__handler_t process, + struct machine *machine) +{ + union perf_event event = { + .time_conv = { + .header = { + .type = PERF_RECORD_TIME_CONV, + .size = sizeof(struct perf_record_time_conv), + }, + }, + }; + struct perf_tsc_conversion tc; + int err; + + if (!pc) + return 0; + err = perf_read_tsc_conversion(pc, &tc); + if (err == -EOPNOTSUPP) + return 0; + if (err) + return err; + + pr_debug2("Synthesizing TSC conversion information\n"); + + event.time_conv.time_mult = tc.time_mult; + event.time_conv.time_shift = tc.time_shift; + event.time_conv.time_zero = tc.time_zero; + + return process(tool, &event, NULL, machine); +} + u64 __weak rdtsc(void) { return 0; From patchwork Mon Sep 14 11:53:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11773627 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DFE7C59D for ; Mon, 14 Sep 2020 11:55:28 +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 B223421D1A for ; Mon, 14 Sep 2020 11:55:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="xHlivHzF"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jN2Nodok" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B223421D1A 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+patchwork-linux-arm=patchwork.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=Z6n9WXcCdZVuXfXnake3uKZ3HUisKXzqGEISbukOTL0=; b=xHlivHzFrumW2FJMG0thDcf4kb kJetpAqil8URklYBovP1bvcucz4VB8wn9lVc+QjBd5niQXoRnvtiJVnJ6pu7lASdDAZdutEB9f1KJ P4Xf7OFGRvMTKHMrq68B4LdjcqwlnOOPjyfYvxWDbqeGJKOPMa/Lt+jCLLAv0jYlG/uO2sqRkHM/u 6np/q1/2Gywd9mgP1tj9HC+8EDQId/vluK6rDVqZGTkfftRcM2OQKg7XliBpL0iCXB1R+xhkKfxeU lKpWj6QGiJ2g+PQz9rWCjX425Fy4A44Zq8Q9SGIGorO/Uui5N8QPrZt/TBX0O8fDmQJbCCePbDkmh dsHhvCNg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn4n-0007yU-1j; Mon, 14 Sep 2020 11:55:17 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn4h-0007wn-Sd for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 11:55:14 +0000 Received: by mail-pf1-x444.google.com with SMTP id o68so12557411pfg.2 for ; Mon, 14 Sep 2020 04:55:11 -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=IaSLSMOw5IWqW5et4rXV7onS1Eb2MpKZtJ8PkFCqqpQ=; b=jN2Nodok2f44UjLuI6RwmJ6F0perVG/SjqBnoUwC14KhAruCkNXi+YxMeOdX8u4NWH UsPwjBotAmgdqlLbFIyyTW9fsMOjd50OZl98z4E6QkIK6alfixogirPR2gSa9Yb5MRR5 FFheGNClwqk7XkwySM2Ch7pJPJZ2XjnEf4sFiiJw+9iJD7XDgY28BDA3rgDgfvZkmAli Am7B4vRVE8veGc4eXGHnbFC3o2SnUF9jM9bozjpV/DKSfiDmza1FMqDn2LLZeuteUOYY Z+y7wCujYbA4agwP0/7c1SQRfiaPyJlBdrEoTOTY1COrqhxd89tnp4+dzux96fj0Ll8e XZpQ== 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=IaSLSMOw5IWqW5et4rXV7onS1Eb2MpKZtJ8PkFCqqpQ=; b=P7VVi6Q1wAqjsYuJ7Nmt7GSwuk9LTeKattvrePdibGaA9LklDZ0pTBD6redGK3WsVy DFl0uteGvo5A2Phh9Vle3/G+SlXvTuFWuCyMkvNIwXERKUCTsSQktU199x4YIKm6DeoC kDoHF8ehff94VXmL+nRtjoafg8/djZ81Ww7hLQ2MNYqUkBTayUz9gqdeQLOJ2jTGHRcx uTlKqqqqVXGJnb02ftqf1/4VsYiPXSm4HvxH+V9BQgX+2uyMvTGSyFKH86zRvM6N3tLr hQSxUvbJ5+n1FgI3mhfszQxfxNbJ7zUr4cUioFJCNYxhHVzZ0PjD+llPZ0hNuCHX28Uz Tm2Q== X-Gm-Message-State: AOAM531DjLNjU1sAFLdMyX33xbwgFnTdWqygoBcprUaFx+HbUHv3zRDV S7mdBsfTq59jB9ZNeS6EOGDEUw== X-Google-Smtp-Source: ABdhPJwGkXwVhJDWvoVTteJpq/PxlhK3ELJ97elqqV4V+nd3pbnJxnqmo5HPRgvGZLjIOmRBPYQ/Uw== X-Received: by 2002:a63:4e52:: with SMTP id o18mr10419275pgl.171.1600084509540; Mon, 14 Sep 2020 04:55:09 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id n2sm9583614pja.41.2020.09.14.04.55.08 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Sep 2020 04:55:09 -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 2/6] perf tsc: Add rdtsc() for Arm64 Date: Mon, 14 Sep 2020 19:53:07 +0800 Message-Id: <20200914115311.2201-3-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_075511_965174_6F5C8F7C X-CRM114-Status: GOOD ( 19.90 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [2600:3c01:0:0:f03c:91ff:fe8a:bb03 listed in] [zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:444 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The system register CNTVCT_EL0 can be used to retrieve the counter from user space. Add rdtsc() for Arm64. Signed-off-by: Leo Yan --- tools/perf/arch/arm64/util/Build | 1 + tools/perf/arch/arm64/util/tsc.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tools/perf/arch/arm64/util/tsc.c diff --git a/tools/perf/arch/arm64/util/Build b/tools/perf/arch/arm64/util/Build index 5c13438c7bd4..b53294d74b01 100644 --- a/tools/perf/arch/arm64/util/Build +++ b/tools/perf/arch/arm64/util/Build @@ -1,6 +1,7 @@ perf-y += header.o perf-y += machine.o perf-y += perf_regs.o +perf-y += tsc.o perf-$(CONFIG_DWARF) += dwarf-regs.o perf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o perf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o diff --git a/tools/perf/arch/arm64/util/tsc.c b/tools/perf/arch/arm64/util/tsc.c new file mode 100644 index 000000000000..cc85bd9e73f1 --- /dev/null +++ b/tools/perf/arch/arm64/util/tsc.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include + +#include "../../../util/tsc.h" + +u64 rdtsc(void) +{ + u64 val; + + /* + * According to ARM DDI 0487F.c, from Armv8.0 to Armv8.5 inclusive, the + * system counter is at least 56 bits wide; from Armv8.6, the counter + * must be 64 bits wide. So the system counter could be less than 64 + * bits wide and it is attributed with the flag 'cap_user_time_short' + * is true. + */ + asm volatile("mrs %0, cntvct_el0" : "=r" (val)); + + return val; +} From patchwork Mon Sep 14 11:53:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11773629 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 254E492C for ; Mon, 14 Sep 2020 11:55: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 EC35721D1A for ; Mon, 14 Sep 2020 11:55:33 +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 EC35721D1A 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+patchwork-linux-arm=patchwork.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-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [2600:3c01:0:0:f03c:91ff:fe8a:bb03 listed in] [zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:541 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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; From patchwork Mon Sep 14 11:53:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11773631 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DF1B59D for ; Mon, 14 Sep 2020 11:55:46 +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 2B0D0221E5 for ; Mon, 14 Sep 2020 11:55:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="lVmV7fUw"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="onU8Na4N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B0D0221E5 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+patchwork-linux-arm=patchwork.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=Nlfz0DY+t0rhCvuWNWhHq9FoNZFthTVbLz0YcssxbUM=; b=lVmV7fUwmGx2Xisv68bQ8JjSb3 zWU1GeVn02QCEn7Mn146DxXlUiKUbdBrBDaOrFuaD51nTh2fVr7gBzYcIqcoFBp6GqfN6lYznvTwT rCUcXDivg3LspErNm354nl3jF5BUvabZzgDhTLTC5A5VwV493FHw3g/okxf/JntXl8WAKY78pIN1X WA3s8Np5XH8deTQA13Sk16LDir/rHJV9048pmBBK43tZxtNkEc/+ub6IocHqPFMkYRVhEz+YO/AAl ib6JJdbsmaVIZwdhj/hOQNSMYeUYUEcY8nft4woGtRU0LJs7cpMQRGAfUaih7uqFP6rNJZdq3K1tV KAt9ZpOQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn53-000842-RH; Mon, 14 Sep 2020 11:55:33 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn50-00082R-RW for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 11:55:31 +0000 Received: by mail-pf1-x444.google.com with SMTP id d6so12423299pfn.9 for ; Mon, 14 Sep 2020 04:55:30 -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=xSOVJj4da1tYC6z/DHA41bMoIW3TylIOsXwZcMYjIwM=; b=onU8Na4NQzsCjz1LdUqLJrE8OJCGofjylUiz2cNQ7o3o7sX3hOjQ/1wsX753/HwF6Z N+GDj/Q3M7N4vyAhOM83oW75+L4n3+6/3PINbSS+t2xfoByvhdbaPCmeXbubyOBT2ZYh af+ehDjGSxH5twfoUeND5K/STAO+iWETgv5ciaZT+JpYLbuNgi5bTK8dohZhGSnOEIZ4 7gnMOAOpVDevGnxA2ZpCMm6Zgvr9AY6rk7qlZXcll561RsDNrVJcdKYLmdCiEmh757eb Y5kFltQoLnYL3OM615QGzGtgGKv3G2f69HASbgbCftZFuXa8fOv2vZ1w7324lbPOq1X/ iHfg== 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=xSOVJj4da1tYC6z/DHA41bMoIW3TylIOsXwZcMYjIwM=; b=jVMxeokvzm5th0mH5ay5SRivUs92nkrTUtku5uX/CYbWYQ8u8DVl30UneBDPwunltH F/EO5n0oa9iQbI3nxKDzr1tZ5nAh6YfDyE0MeUMV7Ia2b3W6Q2VbDEYRMT1D2KK84UI2 GB0FKwvdaQgU5X21rjXHpUt/uz/t75+b6NWrDgn4w2yj7EhHsXGHjrPOGi9GnMA07uc8 EhcMd+nv7QToKD6d2CW6t6FM5l6ctus7y7I6fJ0Pf7HLbvb9ZV7Vk6iejHpZFZ4/m0iR l6OhaIdhLaiRqkjlGAFXkGVdaILbxb93XIld0m4NLnleZVawmbzToUUzNo1oTmYsNPKQ IIcw== X-Gm-Message-State: AOAM530QBtfTXAfeoHcI0Gf4o/ZrGpbhr3Tro52+KN6nzyIkFqvstRUl NKto38F/kCi5wHi8o6vQqmQ8VQ== X-Google-Smtp-Source: ABdhPJw2OSvlqzGVUzejMKvUgrbZ8/qbT/xYRowKcqOQk7FgKYewgBRxBguBZxrEvtodbEfeLHCjAw== X-Received: by 2002:a17:902:a715:b029:d0:89f3:28cf with SMTP id w21-20020a170902a715b02900d089f328cfmr14060884plq.11.1600084529030; Mon, 14 Sep 2020 04:55:29 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id 137sm10620313pfu.149.2020.09.14.04.55.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Sep 2020 04:55:28 -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 4/6] perf tsc: Support cap_user_time_short for event TIME_CONV Date: Mon, 14 Sep 2020 19:53:09 +0800 Message-Id: <20200914115311.2201-5-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_075530_931505_0DBC5E1C X-CRM114-Status: GOOD ( 16.02 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [2600:3c01:0:0:f03c:91ff:fe8a:bb03 listed in] [zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:444 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The synthesized event TIME_CONV doesn't contain the complete parameters for counters, this will lead to wrong conversion between counter cycles and timestamp. This patch extends event TIME_CONV to record flags 'cap_user_time_zero' which is used to indicate the counter parameters are valid or not, if not will directly return 0 for timestamp calculation. And record the flag 'cap_user_time_short' and its relevant fields 'time_cycles' and 'time_mask' for cycle calibration. Signed-off-by: Leo Yan --- tools/lib/perf/include/perf/event.h | 4 ++++ tools/perf/util/jitdump.c | 14 +++++++++----- tools/perf/util/tsc.c | 4 ++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h index 842028858d66..a6dbba6b9073 100644 --- a/tools/lib/perf/include/perf/event.h +++ b/tools/lib/perf/include/perf/event.h @@ -324,6 +324,10 @@ struct perf_record_time_conv { __u64 time_shift; __u64 time_mult; __u64 time_zero; + __u64 time_cycles; + __u64 time_mask; + bool cap_user_time_zero; + bool cap_user_time_short; }; struct perf_record_header_feature { diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c index 0804308ef285..055bab7a92b3 100644 --- a/tools/perf/util/jitdump.c +++ b/tools/perf/util/jitdump.c @@ -374,11 +374,15 @@ static uint64_t convert_timestamp(struct jit_buf_desc *jd, uint64_t timestamp) if (!jd->use_arch_timestamp) return timestamp; - tc.time_shift = jd->session->time_conv.time_shift; - tc.time_mult = jd->session->time_conv.time_mult; - tc.time_zero = jd->session->time_conv.time_zero; - - if (!tc.time_mult) + tc.time_shift = jd->session->time_conv.time_shift; + tc.time_mult = jd->session->time_conv.time_mult; + tc.time_zero = jd->session->time_conv.time_zero; + tc.time_cycles = jd->session->time_conv.time_cycles; + tc.time_mask = jd->session->time_conv.time_mask; + tc.cap_user_time_zero = jd->session->time_conv.cap_user_time_zero; + tc.cap_user_time_short = jd->session->time_conv.cap_user_time_short; + + if (!tc.cap_user_time_zero) return 0; return tsc_to_perf_time(timestamp, &tc); diff --git a/tools/perf/util/tsc.c b/tools/perf/util/tsc.c index c0ca40204649..62b4c75c966c 100644 --- a/tools/perf/util/tsc.c +++ b/tools/perf/util/tsc.c @@ -98,6 +98,10 @@ int perf_event__synth_time_conv(const struct perf_event_mmap_page *pc, event.time_conv.time_mult = tc.time_mult; event.time_conv.time_shift = tc.time_shift; event.time_conv.time_zero = tc.time_zero; + event.time_conv.time_cycles = tc.time_cycles; + event.time_conv.time_mask = tc.time_mask; + event.time_conv.cap_user_time_zero = tc.cap_user_time_zero; + event.time_conv.cap_user_time_short = tc.cap_user_time_short; return process(tool, &event, NULL, machine); } From patchwork Mon Sep 14 11:53:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11773633 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0E70692C for ; Mon, 14 Sep 2020 11:55:59 +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 D13B422207 for ; Mon, 14 Sep 2020 11:55:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="l4pvuGU7"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mFz+j23/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D13B422207 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+patchwork-linux-arm=patchwork.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=VFNkYr7djlIfLjD3afPvLmm6HM4yywOLJNIxAQUas40=; b=l4pvuGU7wBjvOIZGRdqHYFMEBO sSlDlIqW4XaCrZi/4KNyMt1szAVlDhn+agmYgCyRcqOdBS8AatpkQUC4DfEbbqJuQbkZ/g7X0AATx iMsTUtsIXWDSTaulJV3SIkp/Krn4cU1TYMd6At/5H5JfQX4IJVIUJnoQKUeAo+HH78nJnL95q1pcf lNQaBQPAm/HrH3YNuP36Cos+KxYHiWLzdPK+k30TtC/BmozlyFE7gKh1ufxmOhIxH/IX5OGqKzVPQ exCfCPtmjevuFzsL2t6CN/KHDWPHx79QLmcHCiJ+TLfjDYw9cHjQosDwuQlTZ/D9vdIZkG1T/yZt0 v/HP4Cvg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn5D-00087B-4u; Mon, 14 Sep 2020 11:55:43 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn57-00084c-My for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 11:55:39 +0000 Received: by mail-pj1-x1043.google.com with SMTP id u3so5240794pjr.3 for ; Mon, 14 Sep 2020 04:55:36 -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=aOBJ9MjoirS+L5o0/6ixv/rHOD5sDCECP2wua5enYLg=; b=mFz+j23/DsHUjdmzVxlu9gnTp4M+x6SJ0Zt+v+cAtC5fobW/aJnu0UsSswHbY1B+1n uQzsa/PL/7EhePWKjquPfTPYyhVbxqKxTxnd0KhIPA0f+p+1uvMHQ1WgKjBBUoo5QPkq wjw9UvnrHMoySGqQ8T1WuVS85EPZCUuJJ8Ra3UZRRXEbL9rYZdTKzSGwr/HLlFlV3U61 6snzU8WsY0UReB6koWGVldvJEG38Mm/rdlkKPMKjFaiz2UOSCzR/xMAQbL9JJQzoVV4H GYCD9gRBZDXzOKyqDu/bMtc6rMWpve3JBQmBGfr0A0m/5M0JLg9pRvh/TZ5zRproU74A qVrg== 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=aOBJ9MjoirS+L5o0/6ixv/rHOD5sDCECP2wua5enYLg=; b=ly3guZ02CbNgkLsZlotkaafD9xXtJNEH4eHbbXdQL5E/2xAvoDi2vRBAQZ04p1mjls mGQD+UfhZ2Mg3zAkNR3QeBrLrcDRY/dMIeHTvhConKGwKE5q76AFW66imIJY9YvYjyQn foN88wDwBlJTjq9vieCiVBCAv5a/YTdwYBB+g6w4AvKYB9RCd0hxet3nBiuTYT922YOs DXlFijt1mztdU284v8L5OskvUPd5MoyKBQSulfquOSZeqvhQ3C50tFjiYvL062QO6qU8 KIaPnaxHmApbGyHo4kCFLEsF6xD3CYY8sa2GTnlo3VXFN2zQLfNjv1Dx7YdrwR+9mHON IsvQ== X-Gm-Message-State: AOAM530LkwnWmC8GC9yyMx3zLJCTEVlXRwNUL/18rDKB78SE+L6qqwRI /uQHhYUcvirugQivn3cKQnhsOg== X-Google-Smtp-Source: ABdhPJzhnIQHCZNS8UAApJD38ZxCo2Rc99Md+3WX4LEEgKKEZwud4BYFnFfuxmmdE4J+gt4Uo6j9Bw== X-Received: by 2002:a17:90a:d3cd:: with SMTP id d13mr14452003pjw.70.1600084534577; Mon, 14 Sep 2020 04:55:34 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id i15sm3628675pfk.145.2020.09.14.04.55.33 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Sep 2020 04:55:34 -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 5/6] perf tests tsc: Make tsc testing as a common testing Date: Mon, 14 Sep 2020 19:53:10 +0800 Message-Id: <20200914115311.2201-6-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_075537_999768_0BB57BE3 X-CRM114-Status: GOOD ( 19.44 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [2600:3c01:0:0:f03c:91ff:fe8a:bb03 listed in] [zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1043 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org x86 arch provides the testing for conversion between tsc and perf time, the testing is located in x86 arch folder. Move this testing out from x86 arch folder and place it into the common testing folder, so allows to execute tsc testing on other architectures (e.g. Arm64). Signed-off-by: Leo Yan --- tools/perf/arch/x86/include/arch-tests.h | 1 - tools/perf/arch/x86/tests/Build | 1 - tools/perf/arch/x86/tests/arch-tests.c | 4 ---- tools/perf/tests/Build | 1 + tools/perf/tests/builtin-test.c | 4 ++++ tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c | 0 tools/perf/tests/tests.h | 1 + 7 files changed, 6 insertions(+), 6 deletions(-) rename tools/perf/{arch/x86 => }/tests/perf-time-to-tsc.c (100%) diff --git a/tools/perf/arch/x86/include/arch-tests.h b/tools/perf/arch/x86/include/arch-tests.h index c41c5affe4be..6a54b94f1c25 100644 --- a/tools/perf/arch/x86/include/arch-tests.h +++ b/tools/perf/arch/x86/include/arch-tests.h @@ -7,7 +7,6 @@ struct test; /* Tests */ int test__rdpmc(struct test *test __maybe_unused, int subtest); -int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest); int test__insn_x86(struct test *test __maybe_unused, int subtest); int test__intel_pt_pkt_decoder(struct test *test, int subtest); int test__bp_modify(struct test *test, int subtest); diff --git a/tools/perf/arch/x86/tests/Build b/tools/perf/arch/x86/tests/Build index 2997c506550c..36d4f248b51d 100644 --- a/tools/perf/arch/x86/tests/Build +++ b/tools/perf/arch/x86/tests/Build @@ -3,6 +3,5 @@ perf-$(CONFIG_DWARF_UNWIND) += dwarf-unwind.o perf-y += arch-tests.o perf-y += rdpmc.o -perf-y += perf-time-to-tsc.o perf-$(CONFIG_AUXTRACE) += insn-x86.o intel-pt-pkt-decoder-test.o perf-$(CONFIG_X86_64) += bp-modify.o diff --git a/tools/perf/arch/x86/tests/arch-tests.c b/tools/perf/arch/x86/tests/arch-tests.c index 6763135aec17..bc25d727b4e9 100644 --- a/tools/perf/arch/x86/tests/arch-tests.c +++ b/tools/perf/arch/x86/tests/arch-tests.c @@ -8,10 +8,6 @@ struct test arch_tests[] = { .desc = "x86 rdpmc", .func = test__rdpmc, }, - { - .desc = "Convert perf time to TSC", - .func = test__perf_time_to_tsc, - }, #ifdef HAVE_DWARF_UNWIND_SUPPORT { .desc = "DWARF unwind", diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build index 69bea7996f18..8ddf81447344 100644 --- a/tools/perf/tests/Build +++ b/tools/perf/tests/Build @@ -61,6 +61,7 @@ perf-y += demangle-java-test.o perf-y += pfm.o perf-y += parse-metric.o perf-y += pe-file-parsing.o +perf-y += perf-time-to-tsc.o $(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build $(call rule_mkdir) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 651b8ea3354a..0abb5ce88962 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -345,6 +345,10 @@ static struct test generic_tests[] = { .desc = "PE file support", .func = test__pe_file_parsing, }, + { + .desc = "Convert perf time to TSC", + .func = test__perf_time_to_tsc, + }, { .func = NULL, }, diff --git a/tools/perf/arch/x86/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c similarity index 100% rename from tools/perf/arch/x86/tests/perf-time-to-tsc.c rename to tools/perf/tests/perf-time-to-tsc.c diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index ef0f33c6ba23..60a1c317b8db 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -123,6 +123,7 @@ const char *test__pfm_subtest_get_desc(int subtest); int test__pfm_subtest_get_nr(void); int test__parse_metric(struct test *test, int subtest); int test__pe_file_parsing(struct test *test, int subtest); +int test__perf_time_to_tsc(struct test *test, int subtest); bool test__bp_signal_is_supported(void); bool test__bp_account_is_supported(void); From patchwork Mon Sep 14 11:53:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 11773635 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D00C659D for ; Mon, 14 Sep 2020 11:56:07 +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 9D36D22211 for ; Mon, 14 Sep 2020 11:56:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yC38+91i"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jCgsYkQl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D36D22211 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+patchwork-linux-arm=patchwork.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=2BCC/HJCI0vRDRhoUT8aP91cXgKJEMcOoaGok6S0Gec=; b=yC38+91iQeRNmSfYdO6lGVPxzn 16UTV3x3PYWINUgD2vTOrmyGBVuIF8Q7s0UV+rhsrT/05v4qqsR8J2r0GWTrxqDc8sZamMHSHbP6w fWiGq5efiHSOVC4HpgIIeW66WBlPEBw5zG1HZMDsrMm0tRDm+p5K3fbwPlI96kAJxMLoDQRS1kgjg 9W+p6tmmAmfL4MG7RsUhrtRiV6zwLz1EWPuAUnYDXdbdf91xeXaOZ9df/M8VkddY5a0B+pnzU02/H cQRw4IcT7kpKDYyM/buId4DlzkncMgkqNT0XvmdF7UHbnjcQ9dYGYhkhPtCx4DkfSbeqWKv+G7owA uhUkwuOg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn5O-0008CK-Fz; Mon, 14 Sep 2020 11:55:54 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHn5C-00087c-Qd for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 11:55:45 +0000 Received: by mail-pj1-x1043.google.com with SMTP id fa1so5428009pjb.0 for ; Mon, 14 Sep 2020 04:55:42 -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=USSoWqTLQC6v1WLfARfFq+pVWAIHjEU5sK5PvidLdGc=; b=jCgsYkQlvyk7xLwBgGmTjchRWziS1lk31OKpWV+nkfj8rz/fsxfGpEluTFjXE2TqnV IelfNmdpPlV9uZvIRhhxTDl7I4jqs3GDslfjbrNZhmvSBEFl1uGLijm8P359ozTVWYMB pgB95szyeJAR5EQGmFaOEDcHiRJVvpMAjzfVXcNHFk1CXv9sl/9HzU68lQB6r4AltMXm xBTaYql1fiHKcbpjPL5HGCzzcLvkJb2f2CiH4q4LA0rzpiM6UCL4lt19qGQjYtnUmCIj A/b4GxoaHBuWfzEu1ssTktlVDVtAU967S1D+avCXAcGEzEsysw9wqW+6MHkoMx3119JH Ttlw== 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=USSoWqTLQC6v1WLfARfFq+pVWAIHjEU5sK5PvidLdGc=; b=SqEfZp21EtLfD6oLMFCVsIgx1HPKSPhkLhjp1qRxjYarN5x+rj9pn1pTWji9D2G0BC UYmz/C04OjCmHC4Bc4zphkUIoZUKTOqXp3/0kXC8HzAEJqDcHItgUG4tvEJvqkOSfW3N kJqZ0VQUYr8/fFX2o6jjB30tqCLz9SHJPOiE/6kKLkpU4Gy5S22TIAaRjhI+XEnbmuYD 3hJHbYw4JjTpRZrjQ1oeVnvD+0hDlqo11iHWb9lPbEUIs/j4HEe8C085srxbEzjJRwnj Xe7gRd0/S7d2iJOirvEJqya6WQK0Dvpt3bd1lUPEsGBGbFw+ICy1fFh0ttac29p+eMcW Tsgw== X-Gm-Message-State: AOAM531p0C7NvLG/cPq4/P7yqidbBWZYfTIyP3/haVJBQaD1DMISeixn r1ME7MyV9pKCqBtSZmVcMxf6VQ== X-Google-Smtp-Source: ABdhPJwDDJyYR/9kOYREWO7yiSBLaOJtOd4EQfMPYei15KHGHfhINzf6uZxyrpwLG1vsxF/wiIoGAQ== X-Received: by 2002:a17:90a:db05:: with SMTP id g5mr14210632pjv.22.1600084540825; Mon, 14 Sep 2020 04:55:40 -0700 (PDT) Received: from localhost ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id c9sm3506128pfn.78.2020.09.14.04.55.39 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Sep 2020 04:55:40 -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 6/6] perf tests tsc: Add checking helper is_supported() Date: Mon, 14 Sep 2020 19:53:11 +0800 Message-Id: <20200914115311.2201-7-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_075542_952823_689E851D X-CRM114-Status: GOOD ( 16.96 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (3.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 3.6 RCVD_IN_SBL_CSS RBL: Received via a relay in Spamhaus SBL-CSS [2600:3c01:0:0:f03c:91ff:fe8a:bb03 listed in] [zen.spamhaus.org] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1043 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org So far tsc is enabled on x86_64, i386 and Arm64 architectures, add checking helper to skip this testing for other architectures. Signed-off-by: Leo Yan --- tools/perf/tests/builtin-test.c | 1 + tools/perf/tests/perf-time-to-tsc.c | 13 +++++++++++++ tools/perf/tests/tests.h | 1 + 3 files changed, 15 insertions(+) diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 0abb5ce88962..60682e945f9b 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -348,6 +348,7 @@ static struct test generic_tests[] = { { .desc = "Convert perf time to TSC", .func = test__perf_time_to_tsc, + .is_supported = test__tsc_is_supported, }, { .func = NULL, diff --git a/tools/perf/tests/perf-time-to-tsc.c b/tools/perf/tests/perf-time-to-tsc.c index 026d32ed078e..41dadd4cd097 100644 --- a/tools/perf/tests/perf-time-to-tsc.c +++ b/tools/perf/tests/perf-time-to-tsc.c @@ -171,3 +171,16 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe evlist__delete(evlist); return err; } + +bool test__tsc_is_supported(void) +{ + /* + * Except x86_64/i386 and Arm64, other archs don't support TSC in perf. + * Just enable the test for x86_64/i386 and Arm64 archs. + */ +#if defined(__x86_64__) || defined(__i386__) || defined(__aarch64__) + return true; +#else + return false; +#endif +} diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 60a1c317b8db..9f1eedb21eee 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -128,6 +128,7 @@ int test__perf_time_to_tsc(struct test *test, int subtest); bool test__bp_signal_is_supported(void); bool test__bp_account_is_supported(void); bool test__wp_is_supported(void); +bool test__tsc_is_supported(void); #if defined(__arm__) || defined(__aarch64__) #ifdef HAVE_DWARF_UNWIND_SUPPORT