Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp11491pxv; Wed, 21 Jul 2021 14:04:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGjZJ60xmtrva5ww4oVqWTK7JelOWhmaOuwmvN5L3sPBrJN12wtCMbuyegWDDJQNcRzipC X-Received: by 2002:a92:dd02:: with SMTP id n2mr23964294ilm.259.1626901395954; Wed, 21 Jul 2021 14:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626901395; cv=none; d=google.com; s=arc-20160816; b=SKu5DZbc9h5/vxoisehry/jS2wBX4lGvbf1gPGN7tuLfn+4nBw7vHLZ88tKiHWERnm EMDovPtUTs1kx7Nx+zgeDaRBq8pQP8gh1eTtXbPR5qIQCU/KQo1ykBKce0k9HzYLuiyW 8CEWZOeC26hR85CQkYp/k5bZSsz3EnKtqqJmk4rY/R9Hjy2MARi8D15v2y2U9hXl/mfx E/8fPcm/+IzGMtSI879kfRs3AKK6NnRSSQz929QcDszxAN5ZPtMJ6qBKbz9nS2EF0ZuZ zt2YvMohiL3TtNyIIyzwpfmmel0iDNsq94F4y1hsYWQozLQ8muprZJqrOoPCMqGGEOxn kQJw== 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=CGpixdwO7S1rtC4H5PLra/JF15vH5Z2FO/vDmyJkJCY=; b=eFH4gTld+7iVa3ZqVgPBAnroaDWhtrwWBzRQSAqY44kLmzqo6ZuJ/4L888Z3Ocfrcd 3FEGOWm3WIDgaGUzxMlQaKSYMZb2t60Xvr4sJrGMInHO7KZCShzLpGnukKL0zZSBbJ1u rY+atnA5wGPlqs0G9husMX4FcGw3Fgf2bkDOkUxV0g6/7ktPA/iiU4lBgOHX5Tn3w8Az GVnINSZ1qSeenndZiT1XxrYr7dRL3RjMLkbIL8eNL9emw+Z2/xrIfe4cKqaVNyFVpE70 t2yEgZxworHCAn1LjbTg+mWnY2rdfDqwwmGI2NuqMeIrJj/enCFyt5X4M/7+hk2TS9Og m66A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="zy/yk5Pd"; 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 c15si2123505ioa.59.2021.07.21.14.03.01; Wed, 21 Jul 2021 14:03:15 -0700 (PDT) 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="zy/yk5Pd"; 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 S230051AbhGUPZA (ORCPT + 99 others); Wed, 21 Jul 2021 11:25:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbhGUPYx (ORCPT ); Wed, 21 Jul 2021 11:24:53 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F254C061575 for ; Wed, 21 Jul 2021 09:05:30 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id u126so2549884pfb.8 for ; Wed, 21 Jul 2021 09:05:30 -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=CGpixdwO7S1rtC4H5PLra/JF15vH5Z2FO/vDmyJkJCY=; b=zy/yk5PdgpZ09jUzAIhm6OJ/jZVUOLlg3DrvB4ZhRyXKQ8IJPDCay3t57CzO7CNFph cPQ8TiYVKrWPE3zEsGC7HJzMarSeTSoNnumeO7mF/D2wnviQiYbIvrG+7sJuilZo0TiX MIwwcyil7lfV20bZK6J4vuQZQ1uKJ47OxZ+tXQsSmdZEoW6XBozN/0Px2XLut0pFlLhW 3ipGtwgJhJ4xjCpPXJ9fyJzhBLOlkjEPvdVTVmj3nC8YHoObOMyv6Ichpe9hHRzmJMSA 9DdgXDkG/FVCt08zJDMsqzCr1vH9xqETYfk+hnU6fv1g1rRkYtgXHE40aWSCKOMa8HvF zNXQ== 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=CGpixdwO7S1rtC4H5PLra/JF15vH5Z2FO/vDmyJkJCY=; b=EInbIHtPPxcRhii5BTz7OMt2ivCy4PRpJRAcuRtVTggVM2vcy1mvBGpY/j5+WsZWrO mE65iKn3WlFpfoskwXCfTcnOpiVgk+/X+DzWKaLorqRPbrIk6lQuQUXf6F4Io0MvkBMc n2OQnNwpHOvtUXEipz29GbLqyzxrCRqdf4AwhdcfxxPuTPWK3cGN3hm5kgyY0OcwJSCk S9Zhvif25eY0KpO9tTBxl7YbBCjq8TX+4Dyh4fVekB6OYe3RsAJCiazPe0J/jzKxhp16 sgwqrmc7mYIgu1SYp4uUcNS1P7pW7PDUwZASBGwYBsyrrKJikPZ9B7volwo53ivck56t 8Eeg== X-Gm-Message-State: AOAM530vo8srjRIXQwEyGm2bAOWdg99nA/X6OPnHnewR1mtIBdgIAJYH D6afpiZJ//ueqcIFbXcClNfGaQ== X-Received: by 2002:a63:67c5:: with SMTP id b188mr37038490pgc.333.1626883529937; Wed, 21 Jul 2021 09:05:29 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id p24sm31234336pgl.68.2021.07.21.09.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 09:05:25 -0700 (PDT) Date: Wed, 21 Jul 2021 10:05:23 -0600 From: Mathieu Poirier To: James Clark Cc: acme@kernel.org, coresight@lists.linaro.org, leo.yan@linaro.org, al.grant@arm.com, suzuki.poulose@arm.com, anshuman.khandual@arm.com, mike.leach@linaro.org, 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 v2 6/6] perf cs-etm: Pass unformatted flag to decoder Message-ID: <20210721160523.GA2377909@p14s> References: <20210721150202.32065-1-james.clark@arm.com> <20210721150202.32065-7-james.clark@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210721150202.32065-7-james.clark@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 21, 2021 at 04:02:02PM +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 > --- > .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 4 +- > tools/perf/util/cs-etm.c | 53 ++++++++++++++----- > 2 files changed, 42 insertions(+), 15 deletions(-) > Reviewed-by: Mathieu Poirier Arnaldo, please consider adding this set to your tree. Thanks, Mathieu > diff --git a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c > index ed1f0326f859..9c9039ae6989 100644 > --- a/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c > +++ b/tools/perf/util/cs-etm-decoder/cs-etm-decoder.c > @@ -687,7 +687,7 @@ cs_etm_decoder__create_etm_decoder(struct cs_etm_decoder_params *d_params, > } > > struct cs_etm_decoder * > -cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params, > +cs_etm_decoder__new(int decoders, struct cs_etm_decoder_params *d_params, > struct cs_etm_trace_params t_params[]) > { > struct cs_etm_decoder *decoder; > @@ -732,7 +732,7 @@ cs_etm_decoder__new(int num_cpu, struct cs_etm_decoder_params *d_params, > /* init raw frame logging if required */ > cs_etm_decoder__init_raw_frame_logging(d_params, decoder); > > - for (i = 0; i < num_cpu; i++) { > + for (i = 0; i < decoders; i++) { > ret = cs_etm_decoder__create_etm_decoder(d_params, > &t_params[i], > decoder); > diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c > index 760050ea936d..f4b2bff533f3 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) > { > int i; > u32 etmidr; > u64 architecture; > > - for (i = 0; i < etm->num_cpu; i++) { > + for (i = 0; i < decoders; 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,17 @@ 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; > + /* > + * Each queue can only contain data from one CPU when unformatted, so only one decoder is > + * needed. > + */ > + int decoders = formatted ? etm->num_cpu : 1; > > etmq = zalloc(sizeof(*etmq)); > if (!etmq) > @@ -735,21 +743,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); > > 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)) > 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, &d_params, > + t_params); > > if (!etmq->decoder) > goto out_free; > @@ -777,14 +787,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 +2441,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 +2695,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 +2763,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' */ > @@ -3034,6 +3054,13 @@ int cs_etm__process_auxtrace_info(union perf_event *event, > goto err_delete_thread; > > etm->data_queued = etm->queues.populated; > + /* > + * Print warning in pipe mode, see cs_etm__process_auxtrace_event() and > + * cs_etm__queue_aux_fragment() for details relating to limitations. > + */ > + if (!etm->data_queued) > + pr_warning("CS ETM warning: Coresight decode and TRBE support requires random file access.\n" > + "Continuing with best effort decoding in piped mode.\n\n"); > > return 0; > > -- > 2.28.0 >