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=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 74469C433DB for ; Tue, 2 Feb 2021 23:20:58 +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 16F2C64FC0 for ; Tue, 2 Feb 2021 23:20:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16F2C64FC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com 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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ve7IyvJvuqT4PHSrranoz9+qY9vXm++UlNPsmBx+4Cs=; b=dbUNhnLh4H0cUkGMrg3kQPzzw BN2yZ1EjkvXXXaiAaArXOaQfh4xZoWHj8pkrrS+z2Pk++S9QJBHVfj3MrAQ0cRMXalSIQMbWb3uEe WWdEvQ/MkySeQYpBkYuFVGzD57SYwKVobkxFOn4AKMMbADUc5Wow8doBufONv0XDT3hwNJMyGeYVK 4ybwoHE8xpG0j12954qh0Yi3lemZVEbgGpRM7ftDF+21RPcJT1oHz9eirmQJROcMyHvlP9mM5cYF5 qLnmIkq7P79cKN0A6P4+G/BiA6NmrcIwxGFtfxLWosMWo83giO2AMyuwcf5nnux6jxLUF19P3VaRo PiHlKwuYg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l74xT-0003a5-GQ; Tue, 02 Feb 2021 23:19:43 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l74xQ-0003Zj-BM for linux-arm-kernel@lists.infradead.org; Tue, 02 Feb 2021 23:19:41 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 202A131B; Tue, 2 Feb 2021 15:19:39 -0800 (PST) Received: from [10.57.35.108] (unknown [10.57.35.108]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AECDC3F694; Tue, 2 Feb 2021 15:19:35 -0800 (PST) Subject: Re: [PATCH v2 5/7] perf cs-etm: Add helper cs_etm__get_pid_fmt() To: Leo Yan , Arnaldo Carvalho de Melo , Mathieu Poirier , Mike Leach , Jonathan Corbet , Alexander Shishkin , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , Daniel Kiss , Denis Nikitin , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210202163842.134734-1-leo.yan@linaro.org> <20210202163842.134734-6-leo.yan@linaro.org> From: Suzuki K Poulose Message-ID: <51a1e845-f9a4-3c6e-88a2-c105f5b5adfe@arm.com> Date: Tue, 2 Feb 2021 23:19:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210202163842.134734-6-leo.yan@linaro.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210202_181940_468133_6B380BE0 X-CRM114-Status: GOOD ( 24.12 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2/2/21 4:38 PM, Leo Yan wrote: > This patch adds helper function cs_etm__get_pid_fmt(), by passing > parameter "traceID", it returns the PID format. > > Signed-off-by: Leo Yan > --- > tools/perf/util/cs-etm.c | 43 ++++++++++++++++++++++++++++++++++++++++ > tools/perf/util/cs-etm.h | 1 + > 2 files changed, 44 insertions(+) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index a2a369e2fbb6..8194ddbd01e5 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -7,6 +7,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -156,6 +157,48 @@ int cs_etm__get_cpu(u8 trace_chan_id, int *cpu) > return 0; > } > > +/* > + * The returned PID format is presented by two bits: > + * > + * Bit ETM_OPT_CTXTID: CONTEXTIDR or CONTEXTIDR_EL1 is traced; > + * Bit ETM_OPT_CTXTID2: CONTEXTIDR_EL2 is traced. > + * > + * It's possible that these two bits are set together, this means the tracing > + * contains PIDs for both CONTEXTIDR_EL1 and CONTEXTIDR_EL2. This is a bit confusing. If both the bits are set, the session was run on an EL2 kernel. Thus, the PID is always in CONTEXTIDR_EL2. > + */ > +int cs_etm__get_pid_fmt(u8 trace_chan_id, u64 *pid_fmt) > +{ > + struct int_node *inode; > + u64 *metadata, val; > + > + inode = intlist__find(traceid_list, trace_chan_id); > + if (!inode) > + return -EINVAL; > + > + metadata = inode->priv; > + > + if (metadata[CS_ETM_MAGIC] == __perf_cs_etmv3_magic) { > + val = metadata[CS_ETM_ETMCR]; > + /* CONTEXTIDR is traced */ > + if (val & BIT(ETM_OPT_CTXTID)) > + *pid_fmt = BIT(ETM_OPT_CTXTID); > + } else { > + val = metadata[CS_ETMV4_TRCCONFIGR]; > + > + *pid_fmt = 0; > + > + /* CONTEXTIDR_EL2 is traced */ > + if (val & (BIT(ETM4_CFG_BIT_VMID) | BIT(ETM4_CFG_BIT_VMID_OPT))) > + *pid_fmt = BIT(ETM_OPT_CTXTID2); > + > + /* CONTEXTIDR_EL1 is traced */ > + if (val & BIT(ETM4_CFG_BIT_CTXTID)) I haven't looked at how this gets used. But, Shouldn't this be : else if (val & BIT(ETM4_CFG_BIT_CTXTID)) ? Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel