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.2 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,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 C4FE1C636C8 for ; Tue, 20 Jul 2021 15:47:04 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 97B79610F7 for ; Tue, 20 Jul 2021 15:47:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97B79610F7 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=/vN5jqOYEJ/AFvSwA7e86X2shm/TLTIuEkowYAYeokM=; b=33y8wNpC22BoIv 3qGaEfV9TZ2ZXO1plGh5l/AAJDCz3l9cJo/cYw3ZnIggL4AVqWFQLS3xS7BJ6Wi59+si3/GZqf3SI PzgyPmJXVYWP/gPLrelzwvkAMmEX/D3PkbGP1oIkecXsfBi2rpx9LbNAu8pnGYT03rzgHyYDNg+6Y s45EvLMx8NF6+0/eECUMjXbyjKSvP6xn6azAUJOiQlTOj4sY87Me+5b4xgSNY6n02hjbUzlIBcxCZ 2ANXLYs7I8thnmqLv+fIGZ8hGzMyWjzfn+g5+uY3gKwrGciVJpJOR0el+/mUXT5I4BAaR/xJuYxEN qoFAwbwpk2UKUgsBCYHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5rwK-00DT7x-GG; Tue, 20 Jul 2021 15:45:48 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m5rwF-00DT6i-PD for linux-arm-kernel@lists.infradead.org; Tue, 20 Jul 2021 15:45:45 +0000 Received: by mail-pj1-x1035.google.com with SMTP id v18-20020a17090ac912b0290173b9578f1cso2077502pjt.0 for ; Tue, 20 Jul 2021 08:45:43 -0700 (PDT) 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=NpNq7JDQIJsNXoJR8EGd3wRq6OdERgGrM4wiXizuMoU=; b=RAuytij50B1HtqFlhb1ThqAgMNg6BilfhB9jx0mtyAl5MTDm6gG16mEu5rVsJzWSrQ XPoh8svdvJkX3t4NrtKUmhgV0MZ5qwtj/qGZd9qJCLJS/A03WCGsFN+NY21PQBE3ecW2 xg3j6RUl5iRt1x2c20NK09b3Ji9uwdQSc0kLt9A4YONoQMVLsLD8ushCp4gwdY7nUX8G ARHH5DPWnC//phZHPZm088DpkQE2+MI/mMMM2yCLzZylzalGflVUdYMyquY2cHRq/s54 3XTSHK6ECup1XMgZJAfcjSCj71kDYPo2r5c7OJR5EMduG1Ai6ab7kHC/hYaz0aOl8v0d 0GMQ== 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=NpNq7JDQIJsNXoJR8EGd3wRq6OdERgGrM4wiXizuMoU=; b=uKybqzrF1KK9P+TbBJwBUEeQ0ElfSU9QsrMrx4o0wOap56WkMjCYCbe8WgMDbOIH9k hbzVzWASEr24RX3bhnhD9z81JzpVbw/ErjY8ilkPqoW8254lC55logfUVmeREkkBTlGM HEuQOS1REu52k9feiAVnnqGtF8KuC45HXAJZ2JuajVwgQKJ+URZr4G6GZc3u4n4Mnrir nRHKBj6//aUlD/zkbeCLAGVRXQbUFBq3+90WTDhy/k1lm94j/owcZanFDvWwS6BLBCF5 lpnwsSJPAvTEYLUG9Gr53JqGYQ/IVA1y0TkKwplm4m2oYs+VuUPLeJ4vkLn7a3NSq2Qk 63HA== X-Gm-Message-State: AOAM531dcVOfckpK/iJaqAKS25hiili3j2r7msFybRDBLtVFOcEWWheA 5J6YHrg27uIpe6/XHnXWubq83g== X-Google-Smtp-Source: ABdhPJytdcE+2qJMEZYiBxTfYvfrc6yNOaa3KyauvEf3q3eOuA1CJjXhvaLgmV4o2xw5yf21dCnZyw== X-Received: by 2002:a17:902:c204:b029:12b:25f7:9d51 with SMTP id 4-20020a170902c204b029012b25f79d51mr23880464pll.77.1626795942702; Tue, 20 Jul 2021 08:45:42 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id m16sm24152897pfo.152.2021.07.20.08.45.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jul 2021 08:45:42 -0700 (PDT) Date: Tue, 20 Jul 2021 09:45:39 -0600 From: Mathieu Poirier To: James Clark Cc: acme@kernel.org, coresight@lists.linaro.org, leo.yan@linaro.org, al.grant@arm.com, branislav.rankov@arm.com, suzuki.poulose@arm.com, anshuman.khandual@arm.com, Mike Leach , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , John Garry , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/6] perf cs-etm: Pass unformatted flag to decoder Message-ID: <20210720154539.GC2296792@p14s> References: <20210713154008.29656-1-james.clark@arm.com> <20210713154008.29656-7-james.clark@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210713154008.29656-7-james.clark@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210720_084543_922623_BCF702CA X-CRM114-Status: GOOD ( 31.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, Jul 13, 2021 at 04:40:08PM +0100, James Clark wrote: > The TRBE (Trace Buffer Extension) feature allows a separate trace buffer > for each trace source, therefore the trace wouldn't need to be > formatted. The driver was introduced in commit 3fbf7f011f24 > ("coresight: sink: Add TRBE driver"). > > The formatted/unformatted mode is encoded in one of the flags of the > AUX record. The first AUX record encountered for each event is used to > determine the mode, and this will persist for the remaining trace that > is either decoded or dumped. > > Signed-off-by: James Clark > --- > tools/perf/util/cs-etm.c | 42 +++++++++++++++++++++++++++------------- > 1 file changed, 29 insertions(+), 13 deletions(-) > > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index 760050ea936d..62769a84a53f 100644 > --- a/tools/perf/util/cs-etm.c > +++ b/tools/perf/util/cs-etm.c > @@ -461,13 +461,14 @@ static void cs_etm__set_trace_param_etmv4(struct cs_etm_trace_params *t_params, > } > > static int cs_etm__init_trace_params(struct cs_etm_trace_params *t_params, > - struct cs_etm_auxtrace *etm) > + struct cs_etm_auxtrace *etm, > + int decoders_per_cpu) > { > int i; > u32 etmidr; > u64 architecture; > > - for (i = 0; i < etm->num_cpu; i++) { > + for (i = 0; i < decoders_per_cpu; i++) { > architecture = etm->metadata[i][CS_ETM_MAGIC]; > > switch (architecture) { > @@ -488,7 +489,8 @@ static int cs_etm__init_trace_params(struct cs_etm_trace_params *t_params, > > static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, > struct cs_etm_queue *etmq, > - enum cs_etm_decoder_operation mode) > + enum cs_etm_decoder_operation mode, > + bool formatted) > { > int ret = -EINVAL; > > @@ -498,7 +500,7 @@ static int cs_etm__init_decoder_params(struct cs_etm_decoder_params *d_params, > d_params->packet_printer = cs_etm__packet_dump; > d_params->operation = mode; > d_params->data = etmq; > - d_params->formatted = true; > + d_params->formatted = formatted; > d_params->fsyncs = false; > d_params->hsyncs = false; > d_params->frame_aligned = true; > @@ -720,11 +722,13 @@ static u32 cs_etm__mem_access(struct cs_etm_queue *etmq, u8 trace_chan_id, > return len; > } > > -static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm) > +static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm, > + bool formatted) > { > struct cs_etm_decoder_params d_params; > struct cs_etm_trace_params *t_params = NULL; > struct cs_etm_queue *etmq; > + int decoders_per_cpu = formatted ? etm->num_cpu : 1; I really tripped on the name "decoders_per_cpu", to a point where I had to review the current code before looking at this patch. I find the "_per_cpu" part especially puzzling. In the end the variable determines the amount of decoders to instantiate for a specific queue... Couldn't it be just "decoders"? Or maybe it just needs a little comment to disambiguate things? Thanks, Mathieu > > etmq = zalloc(sizeof(*etmq)); > if (!etmq) > @@ -735,21 +739,23 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm) > goto out_free; > > /* Use metadata to fill in trace parameters for trace decoder */ > - t_params = zalloc(sizeof(*t_params) * etm->num_cpu); > + t_params = zalloc(sizeof(*t_params) * decoders_per_cpu); > > if (!t_params) > goto out_free; > > - if (cs_etm__init_trace_params(t_params, etm)) > + if (cs_etm__init_trace_params(t_params, etm, decoders_per_cpu)) > goto out_free; > > /* Set decoder parameters to decode trace packets */ > if (cs_etm__init_decoder_params(&d_params, etmq, > dump_trace ? CS_ETM_OPERATION_PRINT : > - CS_ETM_OPERATION_DECODE)) > + CS_ETM_OPERATION_DECODE, > + formatted)) > goto out_free; > > - etmq->decoder = cs_etm_decoder__new(etm->num_cpu, &d_params, t_params); > + etmq->decoder = cs_etm_decoder__new(decoders_per_cpu, &d_params, > + t_params); > > if (!etmq->decoder) > goto out_free; > @@ -777,14 +783,15 @@ static struct cs_etm_queue *cs_etm__alloc_queue(struct cs_etm_auxtrace *etm) > > static int cs_etm__setup_queue(struct cs_etm_auxtrace *etm, > struct auxtrace_queue *queue, > - unsigned int queue_nr) > + unsigned int queue_nr, > + bool formatted) > { > struct cs_etm_queue *etmq = queue->priv; > > if (list_empty(&queue->head) || etmq) > return 0; > > - etmq = cs_etm__alloc_queue(etm); > + etmq = cs_etm__alloc_queue(etm, formatted); > > if (!etmq) > return -ENOMEM; > @@ -2430,8 +2437,14 @@ static int cs_etm__process_auxtrace_event(struct perf_session *session, > if (err) > return err; > > + /* > + * Knowing if the trace is formatted or not requires a lookup of > + * the aux record so only works in non-piped mode where data is > + * queued in cs_etm__queue_aux_records(). Always assume > + * formatted in piped mode (true). > + */ > err = cs_etm__setup_queue(etm, &etm->queues.queue_array[idx], > - idx); > + idx, true); > if (err) > return err; > > @@ -2678,6 +2691,7 @@ static int cs_etm__queue_aux_fragment(struct perf_session *session, off_t file_o > union perf_event auxtrace_fragment; > __u64 aux_offset, aux_size; > __u32 idx; > + bool formatted; > > struct cs_etm_auxtrace *etm = container_of(session->auxtrace, > struct cs_etm_auxtrace, > @@ -2745,7 +2759,9 @@ static int cs_etm__queue_aux_fragment(struct perf_session *session, off_t file_o > return err; > > idx = auxtrace_event->idx; > - return cs_etm__setup_queue(etm, &etm->queues.queue_array[idx], idx); > + formatted = !(aux_event->flags & PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW); > + return cs_etm__setup_queue(etm, &etm->queues.queue_array[idx], > + idx, formatted); > } > > /* Wasn't inside this buffer, but there were no parse errors. 1 == 'not found' */ > -- > 2.28.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel