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

perf arm-spe: Support multiple Arm SPE events

As the flag 'auxtrace' has been set for Arm SPE events, now it is ready
to use evsel__is_aux_event() to check if an event is AUX trace event or
not. Use this function to replace the old checking for only the first
Arm SPE event.

Signed-off-by: Leo Yan <leo.yan@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: James Clark <james.clark@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: <coresight@lists.linaro.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: <linux-perf-users@vger.kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Leo Yan and committed by
Arnaldo Carvalho de Melo
1635bdca ccd6fcda

+24 -13
+24 -13
tools/perf/arch/arm64/util/arm-spe.c
··· 8 8 #include <linux/types.h> 9 9 #include <linux/bitops.h> 10 10 #include <linux/log2.h> 11 + #include <linux/string.h> 11 12 #include <linux/zalloc.h> 12 13 #include <time.h> 13 14 ··· 178 177 { 179 178 struct arm_spe_recording *sper = 180 179 container_of(itr, struct arm_spe_recording, itr); 181 - struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu; 182 - struct evsel *evsel, *arm_spe_evsel = NULL; 180 + struct evsel *evsel, *tmp; 183 181 struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; 184 182 bool privileged = perf_event_paranoid_check(-1); 185 183 struct evsel *tracking_evsel; ··· 187 187 sper->evlist = evlist; 188 188 189 189 evlist__for_each_entry(evlist, evsel) { 190 - if (evsel->core.attr.type == arm_spe_pmu->type) { 191 - if (arm_spe_evsel) { 192 - pr_err("There may be only one " ARM_SPE_PMU_NAME "x event\n"); 190 + if (evsel__is_aux_event(evsel)) { 191 + if (!strstarts(evsel->pmu_name, ARM_SPE_PMU_NAME)) { 192 + pr_err("Found unexpected auxtrace event: %s\n", 193 + evsel->pmu_name); 193 194 return -EINVAL; 194 195 } 195 - arm_spe_evsel = evsel; 196 196 opts->full_auxtrace = true; 197 197 } 198 198 } ··· 257 257 pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME, 258 258 opts->auxtrace_snapshot_size); 259 259 260 - arm_spe_setup_evsel(arm_spe_evsel, cpus); 260 + evlist__for_each_entry_safe(evlist, tmp, evsel) { 261 + if (evsel__is_aux_event(evsel)) 262 + arm_spe_setup_evsel(evsel, cpus); 263 + } 261 264 262 265 /* Add dummy event to keep tracking */ 263 266 err = parse_event(evlist, "dummy:u"); ··· 310 307 struct arm_spe_recording *ptr = 311 308 container_of(itr, struct arm_spe_recording, itr); 312 309 struct evsel *evsel; 310 + int ret = -EINVAL; 313 311 314 312 evlist__for_each_entry(ptr->evlist, evsel) { 315 - if (evsel->core.attr.type == ptr->arm_spe_pmu->type) 316 - return evsel__disable(evsel); 313 + if (evsel__is_aux_event(evsel)) { 314 + ret = evsel__disable(evsel); 315 + if (ret < 0) 316 + return ret; 317 + } 317 318 } 318 - return -EINVAL; 319 + return ret; 319 320 } 320 321 321 322 static int arm_spe_snapshot_finish(struct auxtrace_record *itr) ··· 327 320 struct arm_spe_recording *ptr = 328 321 container_of(itr, struct arm_spe_recording, itr); 329 322 struct evsel *evsel; 323 + int ret = -EINVAL; 330 324 331 325 evlist__for_each_entry(ptr->evlist, evsel) { 332 - if (evsel->core.attr.type == ptr->arm_spe_pmu->type) 333 - return evsel__enable(evsel); 326 + if (evsel__is_aux_event(evsel)) { 327 + ret = evsel__enable(evsel); 328 + if (ret < 0) 329 + return ret; 330 + } 334 331 } 335 - return -EINVAL; 332 + return ret; 336 333 } 337 334 338 335 static int arm_spe_alloc_wrapped_array(struct arm_spe_recording *ptr, int idx)