Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2203276pxb; Fri, 5 Mar 2021 09:33:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJw61fI7QOACJwof6Q/1lft5o8u27Ea3TytikgaBUt/sXxE5pLYCI2RPrpM/+XDD9X9c8JH9 X-Received: by 2002:a17:906:a106:: with SMTP id t6mr3282043ejy.63.1614965600981; Fri, 05 Mar 2021 09:33:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614965600; cv=none; d=google.com; s=arc-20160816; b=NZFNmD2zrBBcS4QgZyTy/xBmIYQ9knFDwPqd4f4XylGTsFhd/wtlq+aimT8BMPhrSZ f2xY0IDyEgzCDbTQ25rXQGXLiwzQPtgZY0+LkcErwp2GbMfU8BWc3TBIIdXk0pPM2s+/ 3JwthmB/D9e5EF35PXLgm38rd6vKMNSEsy/Ti35UfE7WlIhFNNWRjgOZtRdLeNWRHECz RJTSKYDg0R7NbckNoN8H/Q9B2Zwu/ZUGB9xRiqsrRPzRtMwVZRSZugKVUeiFBpfjx+tG OKwN6gYWbJtFUFG5yxzsgFMV8dWZV3G5HWBCizitHJdW15g/opy23cXFK/S3EJzyTea0 7H5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nxZa/dlPOWlE7blAfUG3/sziBtC9v2Usu1p2UQgmagc=; b=0MOEw01mqVcFVS9HAHTACCowQwweKz3zcK4dGFvO5BVfF0CfbC2q02rGsvyT9YPGY8 VE4vnkWoIJRzFWghnVQjEWlpJKKTlh8O9dBAunO5yR17s+ktgquNV5cnVKxJJ+HNtRCe Z91ZJ/F8GTP43MNeiUy4gcfDGxVCW9/wJre2V72WpDtdN3B0qjO/VjscX8LADYGNw83P 0Cn6+3v4gKNc76khSkeVcOknTknddImORTZYUIE7dyOujvovcTlpofY2630rNAuyNN/c LYlqoOaD6iU5GxWTBGxwc+mlYSz9FT1XijtPoHoTo4ztdUnMWycjjiCy/xpcHAVUm5aG 6z3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QP9DdUp+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si1919341edl.120.2021.03.05.09.32.58; Fri, 05 Mar 2021 09:33:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QP9DdUp+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbhCERba (ORCPT + 99 others); Fri, 5 Mar 2021 12:31:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:51780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229679AbhCERa5 (ORCPT ); Fri, 5 Mar 2021 12:30:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AB0DF65020; Fri, 5 Mar 2021 17:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614965456; bh=CVsvv7UFetXQMMq5IPnSWLmRDhBKI97RD+pTVdoh59w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QP9DdUp+bEXDQFvCjM93ztF7f8GOJVXE2yEOpN8fxjEht6I4KhKTjyA8A2LmnuzIk /74zvQgQL1+Ia4jhoGKD/cuZsgv1Ey3xeAcd9Rl/iJTdl/4Yq1NGLMErfoBKYB6iYb uQdzucQ6dDYESpORgeumLKzjO7BJjkrzLcVSbn3IxCnl7n9LBndHENKs78rJDuvcwP JmDw+nj1Dd5U9s21ocoKbW+4kDHOwwbiSJ1hhe+oni0Kib3KHQIoMZ7VHG4lcVfuDN AtgXXkNyesV5aYJARInuDqR2x/Pz+weLCt3JXMuIN1OZRrtHQa+jXlRyKFsAmH5MeV h3k9y7p0uMBPA== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 3494340647; Fri, 5 Mar 2021 14:30:54 -0300 (-03) Date: Fri, 5 Mar 2021 14:30:54 -0300 From: Arnaldo Carvalho de Melo To: Leo Yan Cc: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Jonathan Corbet , John Garry , Will Deacon , Peter Zijlstra , Ingo Molnar , Mark Rutland , Jiri Olsa , Namhyung Kim , Daniel Kiss , Denis Nikitin , Al Grant , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 5/8] perf cs-etm: Support PID tracing in config Message-ID: References: <20210206150833.42120-1-leo.yan@linaro.org> <20210206150833.42120-6-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210206150833.42120-6-leo.yan@linaro.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sat, Feb 06, 2021 at 11:08:30PM +0800, Leo Yan escreveu: > From: Suzuki K Poulose > > If the kernel is running at EL2, the pid of a task is exposed via VMID > instead of the CONTEXTID. Add support for this in the perf tool. > > This patch respects user setting if user has specified any configs > from "contextid", "contextid1" or "contextid2"; otherwise, it > dynamically sets config based on PMU format "contextid". Since the merge window is closed, I'll continue processing this from here onwards on my perf/core branch, as soon as I get what I have in perf/urgent sent upstream and merged. - Arnaldo > Cc: Mike Leach > Cc: Mathieu Poirier > Cc: Al Grant > Signed-off-by: Suzuki K Poulose > Co-developed-by: Leo Yan > Signed-off-by: Leo Yan > Reviewed-by: Mike Leach > --- > tools/include/linux/coresight-pmu.h | 3 ++ > tools/perf/arch/arm/util/cs-etm.c | 61 +++++++++++++++++++++++------ > 2 files changed, 52 insertions(+), 12 deletions(-) > > diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h > index 5dc47cfdcf07..4ac5c081af93 100644 > --- a/tools/include/linux/coresight-pmu.h > +++ b/tools/include/linux/coresight-pmu.h > @@ -20,14 +20,17 @@ > */ > #define ETM_OPT_CYCACC 12 > #define ETM_OPT_CTXTID 14 > +#define ETM_OPT_CTXTID2 15 > #define ETM_OPT_TS 28 > #define ETM_OPT_RETSTK 29 > > /* ETMv4 CONFIGR programming bits for the ETM OPTs */ > #define ETM4_CFG_BIT_CYCACC 4 > #define ETM4_CFG_BIT_CTXTID 6 > +#define ETM4_CFG_BIT_VMID 7 > #define ETM4_CFG_BIT_TS 11 > #define ETM4_CFG_BIT_RETSTK 12 > +#define ETM4_CFG_BIT_VMID_OPT 15 > > static inline int coresight_get_trace_id(int cpu) > { > diff --git a/tools/perf/arch/arm/util/cs-etm.c b/tools/perf/arch/arm/util/cs-etm.c > index c25c878fd06c..fa6f91a7c8a1 100644 > --- a/tools/perf/arch/arm/util/cs-etm.c > +++ b/tools/perf/arch/arm/util/cs-etm.c > @@ -67,6 +67,7 @@ static int cs_etm_set_context_id(struct auxtrace_record *itr, > char path[PATH_MAX]; > int err = -EINVAL; > u32 val; > + u64 contextid; > > ptr = container_of(itr, struct cs_etm_recording, itr); > cs_etm_pmu = ptr->cs_etm_pmu; > @@ -86,25 +87,59 @@ static int cs_etm_set_context_id(struct auxtrace_record *itr, > goto out; > } > > + /* User has configured for PID tracing, respects it. */ > + contextid = evsel->core.attr.config & > + (BIT(ETM_OPT_CTXTID) | BIT(ETM_OPT_CTXTID2)); > + > /* > - * TRCIDR2.CIDSIZE, bit [9-5], indicates whether contextID tracing > - * is supported: > - * 0b00000 Context ID tracing is not supported. > - * 0b00100 Maximum of 32-bit Context ID size. > - * All other values are reserved. > + * If user doesn't configure the contextid format, parse PMU format and > + * enable PID tracing according to the "contextid" format bits: > + * > + * If bit ETM_OPT_CTXTID is set, trace CONTEXTIDR_EL1; > + * If bit ETM_OPT_CTXTID2 is set, trace CONTEXTIDR_EL2. > */ > - val = BMVAL(val, 5, 9); > - if (!val || val != 0x4) { > - err = -EINVAL; > - goto out; > + if (!contextid) > + contextid = perf_pmu__format_bits(&cs_etm_pmu->format, > + "contextid"); > + > + if (contextid & BIT(ETM_OPT_CTXTID)) { > + /* > + * TRCIDR2.CIDSIZE, bit [9-5], indicates whether contextID > + * tracing is supported: > + * 0b00000 Context ID tracing is not supported. > + * 0b00100 Maximum of 32-bit Context ID size. > + * All other values are reserved. > + */ > + val = BMVAL(val, 5, 9); > + if (!val || val != 0x4) { > + pr_err("%s: CONTEXTIDR_EL1 isn't supported\n", > + CORESIGHT_ETM_PMU_NAME); > + err = -EINVAL; > + goto out; > + } > + } > + > + if (contextid & BIT(ETM_OPT_CTXTID2)) { > + /* > + * TRCIDR2.VMIDOPT[30:29] != 0 and > + * TRCIDR2.VMIDSIZE[14:10] == 0b00100 (32bit virtual contextid) > + * We can't support CONTEXTIDR in VMID if the size of the > + * virtual context id is < 32bit. > + * Any value of VMIDSIZE >= 4 (i.e, > 32bit) is fine for us. > + */ > + if (!BMVAL(val, 29, 30) || BMVAL(val, 10, 14) < 4) { > + pr_err("%s: CONTEXTIDR_EL2 isn't supported\n", > + CORESIGHT_ETM_PMU_NAME); > + err = -EINVAL; > + goto out; > + } > } > > /* All good, let the kernel know */ > - evsel->core.attr.config |= (1 << ETM_OPT_CTXTID); > + evsel->core.attr.config |= contextid; > err = 0; > > out: > - > return err; > } > > @@ -489,7 +524,9 @@ static u64 cs_etmv4_get_config(struct auxtrace_record *itr) > config |= BIT(ETM4_CFG_BIT_TS); > if (config_opts & BIT(ETM_OPT_RETSTK)) > config |= BIT(ETM4_CFG_BIT_RETSTK); > - > + if (config_opts & BIT(ETM_OPT_CTXTID2)) > + config |= BIT(ETM4_CFG_BIT_VMID) | > + BIT(ETM4_CFG_BIT_VMID_OPT); > return config; > } > > -- > 2.25.1 > -- - Arnaldo