Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <james.clark@arm.com>
Cc: Al Grant <Al.Grant@arm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20221212155513.2259623-5-james.clark@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

James Clark and committed by
Arnaldo Carvalho de Melo
fd63091f b00204f5

+9 -17
+9 -17
tools/perf/util/cs-etm.c
··· 2888 2888 int num_cpu, trcidr_idx; 2889 2889 int err = 0; 2890 2890 int i, j; 2891 - u64 *ptr, *hdr = NULL; 2891 + u64 *ptr = NULL; 2892 2892 u64 **metadata = NULL; 2893 2893 u64 hdr_version; 2894 2894 ··· 2914 2914 return -EINVAL; 2915 2915 } 2916 2916 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) & 2926 2919 0xffffffff); 2927 2920 2928 2921 if (dump_trace) ··· 2927 2934 * in anything other than a sequential array is worth doing. 2928 2935 */ 2929 2936 traceid_list = intlist__new(NULL); 2930 - if (!traceid_list) { 2931 - err = -ENOMEM; 2932 - goto err_free_hdr; 2933 - } 2937 + if (!traceid_list) 2938 + return -ENOMEM; 2934 2939 2935 2940 metadata = zalloc(sizeof(*metadata) * num_cpu); 2936 2941 if (!metadata) { 2937 2942 err = -ENOMEM; 2938 2943 goto err_free_traceid_list; 2939 2944 } 2945 + 2946 + /* Start parsing after the common part of the header */ 2947 + i = CS_HEADER_VERSION_MAX; 2940 2948 2941 2949 /* 2942 2950 * The metadata is stored in the auxtrace_info section and encodes ··· 3037 3043 3038 3044 etm->num_cpu = num_cpu; 3039 3045 etm->pmu_type = pmu_type; 3040 - etm->snapshot_mode = (hdr[CS_ETM_SNAPSHOT] != 0); 3046 + etm->snapshot_mode = (ptr[CS_ETM_SNAPSHOT] != 0); 3041 3047 etm->metadata = metadata; 3042 3048 etm->auxtrace_type = auxtrace_info->type; 3043 3049 etm->timeless_decoding = cs_etm__is_timeless_decoding(etm); ··· 3104 3110 zfree(&metadata); 3105 3111 err_free_traceid_list: 3106 3112 intlist__delete(traceid_list); 3107 - err_free_hdr: 3108 - zfree(&hdr); 3109 3113 return err; 3110 3114 }