Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4816pxb; Mon, 8 Feb 2021 13:30:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3SlFYHz4yX23tw7mpRC/MN/LrX4A9qB6lvwiXHKRFDrP37u4ID/EJVtHuUQr+bUCYg5Uf X-Received: by 2002:a17:906:2bd7:: with SMTP id n23mr18999127ejg.502.1612819836173; Mon, 08 Feb 2021 13:30:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612819836; cv=none; d=google.com; s=arc-20160816; b=DyOJnGaF5V37UtJQpHuZ/CvlVXBwBDqhNH0CQ8+1CaXBYVgo5mVOnJABuY7DfguRbv HwtuhpFFkOWqUwWozJTSw46Zh61HDHPfXVCwyjZDK/oo0ff337TRlsGjqi3irfF6ibUS ZreuSho66WuE1pmVTWtfvFvWqfYRiHYR2MTIbJ/PBs+yYlfdzv7bmxLYbjvUfb9Oz9Du 3Yde4iN3zYvRDDxEaRI1OLx0LrWEiWsJE35ppSA4Sc7X3NanDQH+IOfFtYEgSl8mG40c 243KFRBli9fde3BRbQhPFmMtwHwpPmuUaiPq1kXioYGHL7kePbwQPf2JWull+rScaRc6 gjgg== 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=2Diyx5H7hFCC/qQRa303oUug00kOd545GuH0f7jDUVM=; b=AS5qmsRBsIkh7oxlrbunQb54iHquBwpMNgbObmuG76iGpycQx222BfapQXKCtX8v1l yXBqAzwWnVTOd7q/QccO864GagwwawQVkzEm03K0gZqfcbdXsyAWdm/N4eninXpkKIQF dqewYs0DejTJQNuk56zdjmJVvb+DJITsdjX/mcn/ezf+fg8vTjq8hgsynKttDII29tUO Dzat8lPc0STCnNZpeYIFHnyswbgI9n0udc74LeRHsVdEbFGGO8OOApA083xLCtHpaSjZ yoB4x9sys46E9xFmM8cSMIsFw58ki62d0WRQqHm5J3Lh4LhRaAbmGofHu/261kV20GdA B57A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JalFSW/v"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z26si13269307edm.375.2021.02.08.13.30.12; Mon, 08 Feb 2021 13:30:36 -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=@linaro.org header.s=google header.b="JalFSW/v"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236559AbhBHV30 (ORCPT + 99 others); Mon, 8 Feb 2021 16:29:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235180AbhBHUcy (ORCPT ); Mon, 8 Feb 2021 15:32:54 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B332C061788 for ; Mon, 8 Feb 2021 12:32:13 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id z21so11016578pgj.4 for ; Mon, 08 Feb 2021 12:32:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2Diyx5H7hFCC/qQRa303oUug00kOd545GuH0f7jDUVM=; b=JalFSW/vh4gTv+YNGSPEhDmtIsiiS/cJkcxfS1q4czqld/mlzNPCBAijomfLVeT7TG ErMI7Vjgt9VoQrMjSEAmmeqLacIGZISRfWxiLjK5PVIyrozTlhxpNMtQgDXF6Gl72UE4 0785d7PAstzGgv935kTkayHBwH1/bVKlysddPZyoCHA64+jmIlxQAwEl9SnfhMOvKEsS AJZjkCeBfR4FEvIBArfwCkEaPo3y4oTOWSxwn5vv0Kfca9A03rCMeqC/CEHVmV3iPh0o xNO6Xry/Scun49rEan3AG3AbU8a2crduJVsZ4F8elayIOlZYeKisGvi5NO4DdDk9VDMS uyEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2Diyx5H7hFCC/qQRa303oUug00kOd545GuH0f7jDUVM=; b=p5Sr9ZFdo1ollqI/zDwnSZtpzWYdmRxO03LZhnIsGMSVyUAKbtz10yfIrPO4BoJRc2 bTWiWESBg3kg2IetJavMJ94rO7mD3/bu2cNrHEDc4ap8l2aXAQVSg00leL6AN9jYxjhF gSg+MEttgZgwb36pV7xTI+Y19i6hzPSCPZzaIg3rGA06Op7BwpVw1S+wLy1tpba3SKq1 WwCWYb3Jd57VZR/EBi2xGvHu5cxS6gaGHakmWO9i00ZM/KQfXrHZiAtBo6hBpLUXKzkw q/g/ix0CWpup84TXDDydF2lycH2mwElhohCsUVuiWCDT0rg51Wop3jlEsfmmxl8+fw0g nzmQ== X-Gm-Message-State: AOAM531L3NheGCrFLfKPrtcnBFgmhZmmoKY1VBcCRDRibCBkDZ+ikHJj rOYt4xtvX5CYFfixwItrYplL1w== X-Received: by 2002:a62:64c9:0:b029:1b9:6b48:7901 with SMTP id y192-20020a6264c90000b02901b96b487901mr19972798pfb.0.1612816332882; Mon, 08 Feb 2021 12:32:12 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id z31sm147872pjj.47.2021.02.08.12.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Feb 2021 12:32:12 -0800 (PST) Date: Mon, 8 Feb 2021 13:32:10 -0700 From: Mathieu Poirier To: Leo Yan Cc: Arnaldo Carvalho de Melo , 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 6/8] perf cs-etm: Add helper cs_etm__get_pid_fmt() Message-ID: <20210208203210.GC2077938@xps15> References: <20210206150833.42120-1-leo.yan@linaro.org> <20210206150833.42120-7-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210206150833.42120-7-leo.yan@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 06, 2021 at 11:08:31PM +0800, 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 Reviewed-by: Mathieu Poirier > --- > tools/perf/util/cs-etm.c | 42 ++++++++++++++++++++++++++++++++++++++++ > tools/perf/util/cs-etm.h | 1 + > 2 files changed, 43 insertions(+) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index a2a369e2fbb6..b9c1d329a7f1 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,47 @@ 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 the two bits ETM_OPT_CTXTID and ETM_OPT_CTXTID2 > + * are enabled at the same time when the session runs on an EL2 kernel. > + * This means the CONTEXTIDR_EL1 and CONTEXTIDR_EL2 both will be > + * recorded in the trace data, the tool will selectively use > + * CONTEXTIDR_EL2 as PID. > + */ > +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]; > + /* 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 */ > + else if (val & BIT(ETM4_CFG_BIT_CTXTID)) > + *pid_fmt = BIT(ETM_OPT_CTXTID); > + } > + > + return 0; > +} > + > void cs_etm__etmq_set_traceid_queue_timestamp(struct cs_etm_queue *etmq, > u8 trace_chan_id) > { > diff --git a/tools/perf/util/cs-etm.h b/tools/perf/util/cs-etm.h > index 4ad925d6d799..7cc3bba0017d 100644 > --- a/tools/perf/util/cs-etm.h > +++ b/tools/perf/util/cs-etm.h > @@ -173,6 +173,7 @@ struct cs_etm_packet_queue { > int cs_etm__process_auxtrace_info(union perf_event *event, > struct perf_session *session); > int cs_etm__get_cpu(u8 trace_chan_id, int *cpu); > +int cs_etm__get_pid_fmt(u8 trace_chan_id, u64 *pid_fmt); > int cs_etm__etmq_set_tid(struct cs_etm_queue *etmq, > pid_t tid, u8 trace_chan_id); > bool cs_etm__etmq_is_timeless(struct cs_etm_queue *etmq); > -- > 2.25.1 >