Skip to content

Commit fd63091

Browse files
James-A-Clarkacmel
authored andcommitted
perf cs-etm: Cleanup cs_etm__process_auxtrace_info()
hdr is a copy of 3 values of ptr and doesn't need to be long lived. So just use ptr instead which means the malloc and the extra error path can be removed to simplify things. Signed-off-by: James Clark <[email protected]> Cc: Al Grant <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mathieu Poirier <[email protected]> Cc: Mike Leach <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Suzuki Poulouse <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b00204f commit fd63091

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

tools/perf/util/cs-etm.c

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
28882888
int num_cpu, trcidr_idx;
28892889
int err = 0;
28902890
int i, j;
2891-
u64 *ptr, *hdr = NULL;
2891+
u64 *ptr = NULL;
28922892
u64 **metadata = NULL;
28932893
u64 hdr_version;
28942894

@@ -2914,15 +2914,8 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
29142914
return -EINVAL;
29152915
}
29162916

2917-
hdr = zalloc(sizeof(*hdr) * CS_HEADER_VERSION_MAX);
2918-
if (!hdr)
2919-
return -ENOMEM;
2920-
2921-
/* Extract header information - see cs-etm.h for format */
2922-
for (i = 0; i < CS_HEADER_VERSION_MAX; i++)
2923-
hdr[i] = ptr[i];
2924-
num_cpu = hdr[CS_PMU_TYPE_CPUS] & 0xffffffff;
2925-
pmu_type = (unsigned int) ((hdr[CS_PMU_TYPE_CPUS] >> 32) &
2917+
num_cpu = ptr[CS_PMU_TYPE_CPUS] & 0xffffffff;
2918+
pmu_type = (unsigned int) ((ptr[CS_PMU_TYPE_CPUS] >> 32) &
29262919
0xffffffff);
29272920

29282921
if (dump_trace)
@@ -2934,17 +2927,18 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
29342927
* in anything other than a sequential array is worth doing.
29352928
*/
29362929
traceid_list = intlist__new(NULL);
2937-
if (!traceid_list) {
2938-
err = -ENOMEM;
2939-
goto err_free_hdr;
2940-
}
2930+
if (!traceid_list)
2931+
return -ENOMEM;
29412932

29422933
metadata = zalloc(sizeof(*metadata) * num_cpu);
29432934
if (!metadata) {
29442935
err = -ENOMEM;
29452936
goto err_free_traceid_list;
29462937
}
29472938

2939+
/* Start parsing after the common part of the header */
2940+
i = CS_HEADER_VERSION_MAX;
2941+
29482942
/*
29492943
* The metadata is stored in the auxtrace_info section and encodes
29502944
* the configuration of the ARM embedded trace macrocell which is
@@ -3043,7 +3037,7 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
30433037

30443038
etm->num_cpu = num_cpu;
30453039
etm->pmu_type = pmu_type;
3046-
etm->snapshot_mode = (hdr[CS_ETM_SNAPSHOT] != 0);
3040+
etm->snapshot_mode = (ptr[CS_ETM_SNAPSHOT] != 0);
30473041
etm->metadata = metadata;
30483042
etm->auxtrace_type = auxtrace_info->type;
30493043
etm->timeless_decoding = cs_etm__is_timeless_decoding(etm);
@@ -3110,7 +3104,5 @@ int cs_etm__process_auxtrace_info(union perf_event *event,
31103104
zfree(&metadata);
31113105
err_free_traceid_list:
31123106
intlist__delete(traceid_list);
3113-
err_free_hdr:
3114-
zfree(&hdr);
31153107
return err;
31163108
}

0 commit comments

Comments
 (0)