diff mbox series

[v1,5/7] perf cs-etm: Fixup PID_FMT when it is zero

Message ID 20210109074435.626855-6-leo.yan@linaro.org (mailing list archive)
State New, archived
Headers show
Series coresight: etm-perf: Fix pid tracing with VHE | expand

Commit Message

Leo Yan Jan. 9, 2021, 7:44 a.m. UTC
If the metadata item CS_ETM_PID_FMT/CS_ETMV4_PID_FMT is zero, this means
the perf data file is recorded with old version tool and the tool has
not extended to support the item.

For this case, this patch fixes up PID_FMT entry to set the value as
BIT(ETM_OPT_CTXTID), this info will be delivered to the decoder to
extract PID from packet's field "context_id".

Signed-off-by: Leo Yan <leo.yan@linaro.org>
---
 tools/perf/util/cs-etm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Suzuki K Poulose Jan. 11, 2021, 9:47 a.m. UTC | #1
On 1/9/21 7:44 AM, Leo Yan wrote:
> If the metadata item CS_ETM_PID_FMT/CS_ETMV4_PID_FMT is zero, this means
> the perf data file is recorded with old version tool and the tool has
> not extended to support the item.
> 
> For this case, this patch fixes up PID_FMT entry to set the value as
> BIT(ETM_OPT_CTXTID), this info will be delivered to the decoder to
> extract PID from packet's field "context_id".
> 
> Signed-off-by: Leo Yan <leo.yan@linaro.org>

Acked-by: Suzuki K Poulose <suzuki.poulose@arm.com>

> ---
>   tools/perf/util/cs-etm.c | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
> index 763085db29ae..8c125134a756 100644
> --- a/tools/perf/util/cs-etm.c
> +++ b/tools/perf/util/cs-etm.c
> @@ -7,6 +7,7 @@
>    */
>   
>   #include <linux/bitops.h>
> +#include <linux/coresight-pmu.h>
>   #include <linux/err.h>
>   #include <linux/kernel.h>
>   #include <linux/log2.h>
> @@ -2577,6 +2578,15 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>   			for (k = 0; k < metadata_cpu_array_size; k++)
>   				metadata[j][k] = ptr[i + k];
>   
> +			/*
> +			 * If the data in CS_ETM_PID_FMT is zero, means the
> +			 * information isn't stored in the data file, this is
> +			 * because the old perf tool hasn't yet supported
> +			 * CS_ETM_PID_FMT.  Fixup the item to option "CTXTID".
> +			 */
> +			if (!metadata[j][CS_ETM_PID_FMT])
> +				metadata[j][CS_ETM_PID_FMT] = BIT(ETM_OPT_CTXTID);
> +
>   			/* The traceID is our handle */
>   			idx = metadata[j][CS_ETM_ETMTRACEIDR];
>   			i += metadata_cpu_array_size;
> @@ -2590,6 +2600,15 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
>   			for (k = 0; k < metadata_cpu_array_size; k++)
>   				metadata[j][k] = ptr[i + k];
>   
> +			/*
> +			 * If the data in CS_ETMV4_PID_FMT is zero, means the
> +			 * information isn't stored in the data file, this is
> +			 * because the old perf tool hasn't yet supported
> +			 * CS_ETMV4_PID_FMT.  Fixup the item to option "CTXTID".
> +			 */
> +			if (!metadata[j][CS_ETMV4_PID_FMT])
> +				metadata[j][CS_ETMV4_PID_FMT] = BIT(ETM_OPT_CTXTID);
> +
>   			/* The traceID is our handle */
>   			idx = metadata[j][CS_ETMV4_TRCTRACEIDR];
>   			i += metadata_cpu_array_size;
>
diff mbox series

Patch

diff --git a/tools/perf/util/cs-etm.c b/tools/perf/util/cs-etm.c
index 763085db29ae..8c125134a756 100644
--- a/tools/perf/util/cs-etm.c
+++ b/tools/perf/util/cs-etm.c
@@ -7,6 +7,7 @@ 
  */
 
 #include <linux/bitops.h>
+#include <linux/coresight-pmu.h>
 #include <linux/err.h>
 #include <linux/kernel.h>
 #include <linux/log2.h>
@@ -2577,6 +2578,15 @@  int cs_etm__process_auxtrace_info(union perf_event *event,
 			for (k = 0; k < metadata_cpu_array_size; k++)
 				metadata[j][k] = ptr[i + k];
 
+			/*
+			 * If the data in CS_ETM_PID_FMT is zero, means the
+			 * information isn't stored in the data file, this is
+			 * because the old perf tool hasn't yet supported
+			 * CS_ETM_PID_FMT.  Fixup the item to option "CTXTID".
+			 */
+			if (!metadata[j][CS_ETM_PID_FMT])
+				metadata[j][CS_ETM_PID_FMT] = BIT(ETM_OPT_CTXTID);
+
 			/* The traceID is our handle */
 			idx = metadata[j][CS_ETM_ETMTRACEIDR];
 			i += metadata_cpu_array_size;
@@ -2590,6 +2600,15 @@  int cs_etm__process_auxtrace_info(union perf_event *event,
 			for (k = 0; k < metadata_cpu_array_size; k++)
 				metadata[j][k] = ptr[i + k];
 
+			/*
+			 * If the data in CS_ETMV4_PID_FMT is zero, means the
+			 * information isn't stored in the data file, this is
+			 * because the old perf tool hasn't yet supported
+			 * CS_ETMV4_PID_FMT.  Fixup the item to option "CTXTID".
+			 */
+			if (!metadata[j][CS_ETMV4_PID_FMT])
+				metadata[j][CS_ETMV4_PID_FMT] = BIT(ETM_OPT_CTXTID);
+
 			/* The traceID is our handle */
 			idx = metadata[j][CS_ETMV4_TRCTRACEIDR];
 			i += metadata_cpu_array_size;