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=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 DB06FC2D0A3 for ; Thu, 12 Nov 2020 10:01:35 +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 5E3102068E for ; Thu, 12 Nov 2020 10:01:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="z+ac859l"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EfZAtCq2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E3102068E 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+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-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=MTOy3QiuCbUI2faqeo3m3+KCVRfSs+TXPE+p7hFbAQI=; b=z+ac859lUU6xWV0GK1pi3qqFw WZuHTq+uXtqclCnity7JjwNqpLEcUBcrZFSrZdIinIGxtWgZcTTLOmMucAytygIMvef9vSjpONGAl XCVS7Uoc9Td8QB+ApsjO4alLJvE4AxerY8fBBtQA/dIyN7HeJ7GaHmH7tf/yJYR7R6xM5eqyrcVVe rnRs3UweZo3xkYV8ncpHzPApfjPvAQHqeU901wuL5bx3DTXhz660StR28MAOz5xpjOcjwTjeTuzrO Bvh0U0pkM+6975lBu1o2X50WtpGs5wnFRH5Zr9B0StxS8Yt5Up2lBR8Z7xTStCcAcnxXw6CoEzceW wXhV1m5bg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kd9Oy-0000Bb-RK; Thu, 12 Nov 2020 10:00:24 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kd9Ot-0000Af-JD for linux-arm-kernel@lists.infradead.org; Thu, 12 Nov 2020 10:00:20 +0000 Received: by mail-pl1-x642.google.com with SMTP id g11so2505727pll.13 for ; Thu, 12 Nov 2020 02:00:16 -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:user-agent; bh=7u5fn6cQsZv6mFgAcRbTBpSLQqzhGccqcFAoVwz7iPw=; b=EfZAtCq2bQz9KBn0kcMA52XeswtZJb31VQLRDRa+872KGW9cssF0h1MirfpwKQixUF K3+MJ1Spm/XfgZPnsbqhJr015lMWmo8/B5QN81m5m7SaAbDikcU9X2eTkJ05mi6+DAjs b0RgoiwQt8v+16LTjOoIzE6vUXfi1xyP0h3JHrEdomEQeVHoPY+nP4JrTTIPexpw/m99 lJSe2d6/51pUCyoqto0uqd9HlKP3Vu0D5arAFgxmqoDdAzhNMqbUsejQhCgfIqpn6PiR NzkVayAj4ocNd83f4NMlbfIjzUkfujwmCOSBxJJKCuHRu2x3SWX9iWrddviec6zLng/7 DDhQ== 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:user-agent; bh=7u5fn6cQsZv6mFgAcRbTBpSLQqzhGccqcFAoVwz7iPw=; b=YM0rkjJtLM1oWFpWftzHBc69qgJ+zRqAWx2kJEdC2gAX0dfsyL0co4GVPgnMhChrbJ 9Qiisd3XevGpp+JrX/H0ODBpOB4t3HX+XxXzzi/wb6GZEQzdPb7NvBitxgKFyuUhHw1y z8+djBTmfpLMn8S1vdtyL0EWmR1MXEic5QBRCzmqWsHDOXxi56bHSwlWuo8otjiQ1tU+ lm423t9X3mK308F4sD2dhmIF4y8ou62C80G0otYBDtiJjE/pGRAEKDcNHUhorGVQ8dSW xAFKl1SigXoKs+nMzoRR0tfIqB1fEkJWVDW/kbq/sXpjcoXjbHelf3nHrifhg1ybT5/r ogFQ== X-Gm-Message-State: AOAM53202crTue8cmhavhxR3uFnNTkb7oNf1Tl3XLH4fSNFjh1DNUOJb 14UaLTiatF2EKt0Iv+GmfHdAow== X-Google-Smtp-Source: ABdhPJzmiTQOrjlo9+EPqNWFP4iGvLji6SMwd3dJiVmlH2yrLvmbbNoFsvoLvpmw9DvP/zOQi3IkVw== X-Received: by 2002:a17:902:868e:b029:d7:eb0d:79e8 with SMTP id g14-20020a170902868eb02900d7eb0d79e8mr14469614plo.12.1605175215159; Thu, 12 Nov 2020 02:00:15 -0800 (PST) Received: from leoy-ThinkPad-X240s ([103.127.239.100]) by smtp.gmail.com with ESMTPSA id v126sm5678248pfb.137.2020.11.12.02.00.12 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Nov 2020 02:00:14 -0800 (PST) Date: Thu, 12 Nov 2020 18:00:10 +0800 From: Leo Yan To: Suzuki K Poulose Subject: Re: [PATCH 2/3] perf: cs_etm: Use pid tracing explicitly instead of contextid Message-ID: <20201112100010.GB17274@leoy-ThinkPad-X240s> References: <20201110183313.1823760-1-suzuki.poulose@arm.com> <20201110183313.1823760-3-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201110183313.1823760-3-suzuki.poulose@arm.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_050019_706054_73381681 X-CRM114-Status: GOOD ( 33.26 ) 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: al.grant@arm.com, mathieu.poirier@linaro.org, anshuman.khandual@arm.com, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, mike.leach@linaro.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 10, 2020 at 06:33:12PM +0000, Suzuki Kuruppassery Poulose wrote: > If the kernel is running at EL2, the pid of the task is exposed > via VMID instead of the CONTEXTID. Add support for this in the > perf tool. > > By default the perf tool requests contextid and timestamp for > task bound events. Instead of hard coding contextid, switch > to "pid" config exposed by the kernel. > > Cc: Leo Yan > Cc: Mike Leach > Cc: Mathieu Poirier > Cc: Al Grant > Signed-off-by: Suzuki K Poulose > --- > tools/include/linux/coresight-pmu.h | 11 +++-- > tools/perf/arch/arm/util/cs-etm.c | 65 +++++++++++++++++++++-------- > 2 files changed, 54 insertions(+), 22 deletions(-) > > diff --git a/tools/include/linux/coresight-pmu.h b/tools/include/linux/coresight-pmu.h > index b0e35eec6499..927c6285ce5d 100644 > --- a/tools/include/linux/coresight-pmu.h > +++ b/tools/include/linux/coresight-pmu.h > @@ -11,16 +11,19 @@ > #define CORESIGHT_ETM_PMU_SEED 0x10 > > /* ETMv3.5/PTM's ETMCR config bit */ > -#define ETM_OPT_CYCACC 12 > -#define ETM_OPT_CTXTID 14 > -#define ETM_OPT_TS 28 > -#define ETM_OPT_RETSTK 29 > +#define ETM_OPT_CYCACC 12 > +#define ETM_OPT_CTXTID 14 > +#define ETM_OPT_CTXTID_IN_VMID 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 cad7bf783413..e6207ce7cc85 100644 > --- a/tools/perf/arch/arm/util/cs-etm.c > +++ b/tools/perf/arch/arm/util/cs-etm.c > @@ -59,14 +59,15 @@ static const char *metadata_etmv4_ro[CS_ETMV4_PRIV_MAX] = { > > static bool cs_etm_is_etmv4(struct auxtrace_record *itr, int cpu); > > -static int cs_etm_set_context_id(struct auxtrace_record *itr, > - struct evsel *evsel, int cpu) > +static int cs_etm_set_pid(struct auxtrace_record *itr, > + struct evsel *evsel, int cpu) > { > struct cs_etm_recording *ptr; > struct perf_pmu *cs_etm_pmu; > char path[PATH_MAX]; > int err = -EINVAL; > u32 val; > + u64 pid_fmt; > > ptr = container_of(itr, struct cs_etm_recording, itr); > cs_etm_pmu = ptr->cs_etm_pmu; > @@ -86,21 +87,43 @@ static int cs_etm_set_context_id(struct auxtrace_record *itr, > goto out; > } > > - /* > - * 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) { > + pid_fmt = perf_pmu__format_bits(&cs_etm_pmu->format, "pid"); > + if (!pid_fmt) > + pid_fmt = 1ULL << ETM_OPT_CTXTID; If doesn't find "pid" format bits, should it mean the kernel is running an old version so doesn't support "pid" entry? It's good to add comment for this. > + > + switch (pid_fmt) { > + case (1ULL << 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) { > + err = -EINVAL; > + goto out; > + } > + break; > + case (1ULL << ETM_OPT_CTXTID_IN_VMID): > + /* > + * TRCIDR2.VMIDOPT[30:29] != 0 and > + * TRCIDR2.VMIDSIZE[14:10] == 0b00100 (32bit virtual context id size) > + */ > + if (!BMVAL(val, 29, 30) || BMVAL(val, 10, 14) < 4) { The comment is not alignment with the code. Based on the comment, the code should be: if (!BMVAL(val, 29, 30) || BMVAL(val, 10, 14) != 4) { > + err = -EINVAL; > + goto out; > + } > + break; > + default: > err = -EINVAL; > goto out; > } > > + > /* All good, let the kernel know */ > - evsel->core.attr.config |= (1 << ETM_OPT_CTXTID); > + evsel->core.attr.config |= pid_fmt; > err = 0; > > out: > @@ -156,6 +179,10 @@ static int cs_etm_set_timestamp(struct auxtrace_record *itr, > return err; > } > > +#define ETM_SET_OPT_PID (1 << 0) > +#define ETM_SET_OPT_TS (1 << 1) > +#define ETM_SET_OPT_MASK (ETM_SET_OPT_PID | ETM_SET_OPT_TS) > + > static int cs_etm_set_option(struct auxtrace_record *itr, > struct evsel *evsel, u32 option) > { > @@ -169,17 +196,17 @@ static int cs_etm_set_option(struct auxtrace_record *itr, > !cpu_map__has(online_cpus, i)) > continue; > > - if (option & ETM_OPT_CTXTID) { > - err = cs_etm_set_context_id(itr, evsel, i); > + if (option & ETM_SET_OPT_PID) { > + err = cs_etm_set_pid(itr, evsel, i); I don't understand what's the reason for introducing the new macros "ETM_SET_OPT_XXX", seems to me the old macros still can be used at here. Could you help explian for this? Thanks, Leo > if (err) > goto out; > } > - if (option & ETM_OPT_TS) { > + if (option & ETM_SET_OPT_TS) { > err = cs_etm_set_timestamp(itr, evsel, i); > if (err) > goto out; > } > - if (option & ~(ETM_OPT_CTXTID | ETM_OPT_TS)) > + if (option & ~(ETM_SET_OPT_MASK)) > /* Nothing else is currently supported */ > goto out; > } > @@ -406,7 +433,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, > evsel__set_sample_bit(cs_etm_evsel, CPU); > > err = cs_etm_set_option(itr, cs_etm_evsel, > - ETM_OPT_CTXTID | ETM_OPT_TS); > + ETM_SET_OPT_PID | ETM_SET_OPT_TS); > if (err) > goto out; > } > @@ -485,7 +512,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_CTXTID_IN_VMID)) > + config |= BIT(ETM4_CFG_BIT_VMID) | > + BIT(ETM4_CFG_BIT_VMID_OPT); > return config; > } > > -- > 2.24.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel