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

perf tests: Fix Track with sched_switch test for hybrid case

If cpu_core PMU event fails to parse, try also cpu_atom PMU event when
parsing cycles event.

Fixes: 43eb05d066795bdf ("perf tests: Support 'Track with sched_switch' test for hybrid")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220809080702.6921-3-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
1da1d607 2e828582

+13 -5
+13 -5
tools/perf/tests/switch-tracking.c
··· 324 324 static int test__switch_tracking(struct test_suite *test __maybe_unused, int subtest __maybe_unused) 325 325 { 326 326 const char *sched_switch = "sched:sched_switch"; 327 + const char *cycles = "cycles:u"; 327 328 struct switch_tracking switch_tracking = { .tids = NULL, }; 328 329 struct record_opts opts = { 329 330 .mmap_pages = UINT_MAX, ··· 373 372 cpu_clocks_evsel = evlist__last(evlist); 374 373 375 374 /* Second event */ 376 - if (perf_pmu__has_hybrid()) 377 - err = parse_events(evlist, "cpu_core/cycles/u", NULL); 378 - else 379 - err = parse_events(evlist, "cycles:u", NULL); 375 + if (perf_pmu__has_hybrid()) { 376 + cycles = "cpu_core/cycles/u"; 377 + err = parse_events(evlist, cycles, NULL); 378 + if (err) { 379 + cycles = "cpu_atom/cycles/u"; 380 + pr_debug("Trying %s\n", cycles); 381 + err = parse_events(evlist, cycles, NULL); 382 + } 383 + } else { 384 + err = parse_events(evlist, cycles, NULL); 385 + } 380 386 if (err) { 381 - pr_debug("Failed to parse event cycles:u\n"); 387 + pr_debug("Failed to parse event %s\n", cycles); 382 388 goto out_err; 383 389 } 384 390