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.3 required=3.0 tests=BAYES_00, 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=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 71143C433DB for ; Mon, 11 Jan 2021 09:46:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6B3222AAA for ; Mon, 11 Jan 2021 09:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728619AbhAKJqL (ORCPT ); Mon, 11 Jan 2021 04:46:11 -0500 Received: from foss.arm.com ([217.140.110.172]:51576 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728550AbhAKJqL (ORCPT ); Mon, 11 Jan 2021 04:46:11 -0500 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 7FE7F101E; Mon, 11 Jan 2021 01:45:25 -0800 (PST) Received: from [10.57.39.145] (unknown [10.57.39.145]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DE7293F70D; Mon, 11 Jan 2021 01:45:21 -0800 (PST) Subject: Re: [PATCH v1 4/7] perf cs-etm: Add PID format into metadata To: Leo Yan , Arnaldo Carvalho de Melo , Mathieu Poirier , Mike Leach , 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-kernel@vger.kernel.org References: <20210109074435.626855-1-leo.yan@linaro.org> <20210109074435.626855-5-leo.yan@linaro.org> From: Suzuki K Poulose Message-ID: Date: Mon, 11 Jan 2021 09:45:12 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210109074435.626855-5-leo.yan@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Leo, On 1/9/21 7:44 AM, Leo Yan wrote: > It's possible for CoreSight to trace PID in either CONTEXTIDR_EL1 or > CONTEXTIDR_EL2, the PID format info is used to distinguish the PID > is traced in which register. > > This patch saves PID format into the metadata when record. The patch looks good to me. One minor suggestion below > > Signed-off-by: Leo Yan > --- > tools/perf/arch/arm/util/cs-etm.c | 21 +++++++++++++++++++++ > tools/perf/util/cs-etm.c | 2 ++ > tools/perf/util/cs-etm.h | 2 ++ > 3 files changed, 25 insertions(+) > > diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c > index fad7b6e13ccc..ee78df3b1b07 100644 > --- a/tools/perf/arch/arm/util/cs-etm.c > +++ b/tools/perf/arch/arm/util/cs-etm.c > @@ -613,6 +613,7 @@ static void cs_etm_get_metadata(int cpu, u32 *offset, > struct cs_etm_recording *ptr = > container_of(itr, struct cs_etm_recording, itr); > struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; > + u64 pid_fmt; > > /* first see what kind of tracer this cpu is affined to */ > if (cs_etm_is_etmv4(itr, cpu)) { > @@ -641,6 +642,16 @@ static void cs_etm_get_metadata(int cpu, u32 *offset, > metadata_etmv4_ro > [CS_ETMV4_TRCAUTHSTATUS]); > > + /* > + * The PID format will be used when decode the trace data; > + * based on it the decoder will make decision for setting > + * sample's PID as context_id or VMID. > + */ > + pid_fmt = perf_pmu__format_bits(&cs_etm_pmu->format, "pid"); > + if (!pid_fmt) > + pid_fmt = 1ULL << ETM_OPT_CTXTID; > + info->priv[*offset + CS_ETMV4_PID_FMT] = pid_fmt; > + Given we do this same step twice here in this function and also in patch 2. I am wondering if this could be made into a small helper function ? static u64 cs_etm_pmu_format_pid(cs_etm_pm) { pid_fmt = perf_pmu__format_bits(&cs_etm_pmu->format, "pid"); /* * An older kernel doesn't expose this, so fall back to using * CTXTID. */ if (!pid_fmt) pid_fmt = 1ULL << ETM_OPT_CTXTID; return pid_fmt; } Suzuki 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.5 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 4892CC433DB for ; Mon, 11 Jan 2021 09:46:45 +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 EC90122AAA for ; Mon, 11 Jan 2021 09:46:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC90122AAA 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=qROrbTwR2MzMRuhdD5yjATbuX2AsUqP6nt0PnU2df/s=; b=snRQzz6Vks8yzLphqp8uxKru1 SvmbvZJOGZ0vkmGMiS/vbDcFqIzRseAMJxNAt4K8qekmiZdWhfKOkZxQnF6fGA38tRnh68JK/FxKO UxxusfVzLviPpAc5rT+idsSDy59Gk83oKWmXHSyxn0k/lA+RWBLx6BljU0sFRtya8MDDE/7H+34yK 1tf4pFYoCRRMDuSanizQjxJsUxdLunmEfCmG8ro9uorHScGYFnW5oNJioPnoTPGk5jq+zPOzXhBA9 nTi/OIqSmdeIF4gvFjUhpinhKvB7ZnxlbHYRXno1RzV9S74PIQikv2I+IWZTJnkkmz74FB9QhLdVF yj4Q2AmDQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kytlW-000826-5P; Mon, 11 Jan 2021 09:45:34 +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 1kytlT-00080z-2C for linux-arm-kernel@lists.infradead.org; Mon, 11 Jan 2021 09:45:32 +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 7FE7F101E; Mon, 11 Jan 2021 01:45:25 -0800 (PST) Received: from [10.57.39.145] (unknown [10.57.39.145]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DE7293F70D; Mon, 11 Jan 2021 01:45:21 -0800 (PST) Subject: Re: [PATCH v1 4/7] perf cs-etm: Add PID format into metadata To: Leo Yan , Arnaldo Carvalho de Melo , Mathieu Poirier , Mike Leach , 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-kernel@vger.kernel.org References: <20210109074435.626855-1-leo.yan@linaro.org> <20210109074435.626855-5-leo.yan@linaro.org> From: Suzuki K Poulose Message-ID: Date: Mon, 11 Jan 2021 09:45:12 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210109074435.626855-5-leo.yan@linaro.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210111_044531_177076_21C3A1AB X-CRM114-Status: GOOD ( 24.09 ) 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 Hi Leo, On 1/9/21 7:44 AM, Leo Yan wrote: > It's possible for CoreSight to trace PID in either CONTEXTIDR_EL1 or > CONTEXTIDR_EL2, the PID format info is used to distinguish the PID > is traced in which register. > > This patch saves PID format into the metadata when record. The patch looks good to me. One minor suggestion below > > Signed-off-by: Leo Yan > --- > tools/perf/arch/arm/util/cs-etm.c | 21 +++++++++++++++++++++ > tools/perf/util/cs-etm.c | 2 ++ > tools/perf/util/cs-etm.h | 2 ++ > 3 files changed, 25 insertions(+) > > diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c > index fad7b6e13ccc..ee78df3b1b07 100644 > --- a/tools/perf/arch/arm/util/cs-etm.c > +++ b/tools/perf/arch/arm/util/cs-etm.c > @@ -613,6 +613,7 @@ static void cs_etm_get_metadata(int cpu, u32 *offset, > struct cs_etm_recording *ptr = > container_of(itr, struct cs_etm_recording, itr); > struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; > + u64 pid_fmt; > > /* first see what kind of tracer this cpu is affined to */ > if (cs_etm_is_etmv4(itr, cpu)) { > @@ -641,6 +642,16 @@ static void cs_etm_get_metadata(int cpu, u32 *offset, > metadata_etmv4_ro > [CS_ETMV4_TRCAUTHSTATUS]); > > + /* > + * The PID format will be used when decode the trace data; > + * based on it the decoder will make decision for setting > + * sample's PID as context_id or VMID. > + */ > + pid_fmt = perf_pmu__format_bits(&cs_etm_pmu->format, "pid"); > + if (!pid_fmt) > + pid_fmt = 1ULL << ETM_OPT_CTXTID; > + info->priv[*offset + CS_ETMV4_PID_FMT] = pid_fmt; > + Given we do this same step twice here in this function and also in patch 2. I am wondering if this could be made into a small helper function ? static u64 cs_etm_pmu_format_pid(cs_etm_pm) { pid_fmt = perf_pmu__format_bits(&cs_etm_pmu->format, "pid"); /* * An older kernel doesn't expose this, so fall back to using * CTXTID. */ if (!pid_fmt) pid_fmt = 1ULL << ETM_OPT_CTXTID; return pid_fmt; } Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel