From: James Clark <james.clark@arm.com>
To: Mike Leach <mike.leach@linaro.org>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: mathieu.poirier@linaro.org, peterz@infradead.org,
mingo@redhat.com, acme@kernel.org,
linux-perf-users@vger.kernel.org, quic_jinlmao@quicinc.com
Subject: Re: [PATCH v4 11/13] perf: cs-etm: Handle PERF_RECORD_AUX_OUTPUT_HW_ID packet
Date: Mon, 5 Sep 2022 12:36:43 +0100 [thread overview]
Message-ID: <cad6b3c2-f78f-a6c4-25fd-3402b02a4944@arm.com> (raw)
In-Reply-To: <20220823091009.14121-12-mike.leach@linaro.org>
On 23/08/2022 10:10, Mike Leach wrote:
> When using dynamically assigned CoreSight trace IDs the drivers can output
> the ID / CPU association as a PERF_RECORD_AUX_OUTPUT_HW_ID packet.
>
> Update cs-etm decoder to handle this packet by setting the CPU/Trace ID
> mapping.
>
> Signed-off-by: Mike Leach <mike.leach@linaro.org>
> ---
[...]
> - /* before aux records are queued, need to map metadata to trace IDs */
> - err = cs_etm__map_trace_ids_metadata(num_cpu, metadata);
> + /*
> + * Map Trace ID values to CPU metadata.
> + *
> + * Trace metadata will always contain Trace ID values from the legacy algorithm. If the
> + * files has been recorded by a "new" perf updated to handle AUX_HW_ID then the metadata
> + * ID value will also have the CORESIGHT_TRACE_ID_UNUSED_FLAG set.
> + *
> + * The updated kernel drivers that use AUX_HW_ID to sent Trace IDs will attempt to use
> + * the same IDs as the old algorithm as far as is possible, unless there are clashes
> + * in which case a different value will be used. This means an older perf may still
> + * be able to record and read files generate on a newer system.
> + *
> + * For a perf able to interpret AUX_HW_ID packets we first check for the presence of
> + * those packets. If they are there then the values will be mapped and plugged into
> + * the metadata. We then set any remaining metadata values with the used flag to a
> + * value CORESIGHT_TRACE_ID_UNUSED_VAL - which indicates no decoder is required.
> + *
> + * If no AUX_HW_ID packets are present - which means a file recorded on an old kernel
> + * then we map Trace ID values to CPU directly from the metadata - clearing any unused
> + * flags if present.
> + */
> +
> + /* first scan for AUX_OUTPUT_HW_ID records to map trace ID values to CPU metadata */
> + aux_hw_id_found = 0;
> + err = perf_session__peek_events(session, session->header.data_offset,
> + session->header.data_size,
> + cs_etm__process_aux_hw_id_cb, &aux_hw_id_found);
> + if (err)
> + goto err_delete_thread;
> +
> + /* if HW ID found then clear any unused metadata ID values */
> + if (aux_hw_id_found)
> + err = cs_etm__clear_unused_trace_ids_metadata(num_cpu, metadata);
> + /* otherwise, this is a file with metadata values only, map from metadata */
> + else
> + err = cs_etm__map_trace_ids_metadata(num_cpu, metadata);
> +
> if (err)
> goto err_delete_thread;
>
> @@ -3124,13 +3342,14 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>
> etm->data_queued = etm->queues.populated;
> /*
> - * Print warning in pipe mode, see cs_etm__process_auxtrace_event() and
> + * Print error 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");
> -
> + if (!etm->data_queued) {
> + pr_err("CS ETM: Coresight decode and TRBE support need random file access.\n");
> + err = -EINVAL;
> + goto err_delete_thread;
> + }
This error message is never hit because the peek that was added is
followed by:
if (err)
goto err_delete_thread;
Peek will return -1 in pipe mode so then you get this output instead:
./perf record -e cs_etm//u -o - -- ls > stdio.data
cat stdio.data | ./perf report -i -
0x1464 [0x168]: failed to process type: 70
Error:
failed to process sample
It would be simpler to add this new check to the very beginning of
cs_etm__process_auxtrace_info() and print the message/quit there instead:
if (perf_data__is_pipe(session->data))
return -1;
Then etm->data_queued can also be removed because it's always true.
Apart from that issue:
Reviewed-by: James Clark <james.clark@arm.com>
Thanks
James
> return 0;
>
> err_delete_thread:
next prev parent reply other threads:[~2022-09-05 11:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 9:09 [PATCH v4 00/13] coresight: Add new API to allocate trace source ID values Mike Leach
2022-08-23 9:09 ` [PATCH v4 01/13] coresight: trace-id: Add API to dynamically assign Trace " Mike Leach
2022-08-23 9:09 ` [PATCH v4 02/13] coresight: Remove obsolete Trace ID unniqueness checks Mike Leach
2022-08-23 9:09 ` [PATCH v4 03/13] coresight: stm: Update STM driver to use Trace ID API Mike Leach
2022-08-23 9:10 ` [PATCH v4 04/13] coresight: etm4x: Update ETM4 " Mike Leach
2022-08-23 9:10 ` [PATCH v4 05/13] coresight: etm3x: Update ETM3 " Mike Leach
2022-08-23 9:10 ` [PATCH v4 06/13] coresight: etmX.X: stm: Remove trace_id() callback Mike Leach
2022-08-23 9:10 ` [PATCH v4 07/13] coresight: perf: traceid: Add perf notifiers for Trace ID Mike Leach
2022-08-23 9:10 ` [PATCH v4 08/13] perf: cs-etm: Move mapping of Trace ID and cpu into helper function Mike Leach
2022-09-05 11:38 ` James Clark
2022-08-23 9:10 ` [PATCH v4 09/13] perf: cs-etm: Update record event to use new Trace ID protocol Mike Leach
2022-09-05 11:38 ` James Clark
2022-08-23 9:10 ` [PATCH v4 10/13] kernel: events: Export perf_report_aux_output_id() Mike Leach
2022-08-23 9:10 ` [PATCH v4 11/13] perf: cs-etm: Handle PERF_RECORD_AUX_OUTPUT_HW_ID packet Mike Leach
2022-09-05 11:36 ` James Clark [this message]
2022-08-23 9:10 ` [PATCH v4 12/13] coresight: events: PERF_RECORD_AUX_OUTPUT_HW_ID used for Trace ID Mike Leach
2022-08-23 9:10 ` [PATCH v4 13/13] coresight: trace-id: Add debug & test macros to Trace ID allocation Mike Leach
2022-09-05 10:44 ` [PATCH v4 00/13] coresight: Add new API to allocate trace source ID values James Clark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cad6b3c2-f78f-a6c4-25fd-3402b02a4944@arm.com \
--to=james.clark@arm.com \
--cc=acme@kernel.org \
--cc=coresight@lists.linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=quic_jinlmao@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®