Skip to content

Commit

Permalink
perf tests: Fix Convert perf time to TSC test for hybrid
Browse files Browse the repository at this point in the history
The test does not always correctly determine the number of events for
hybrids, nor allow for more than 1 evsel when parsing.

Fix by iterating the events actually created and getting the correct
evsel for the events processed.

Fixes: d9da6f7 ("perf tests: Support 'Convert perf time to TSC' test for hybrid")
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
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>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: https://lore.kernel.org/r/20220713123459.24145-3-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
ahunter6 authored and acmel committed Jul 17, 2022
1 parent 498c7a5 commit deb44a6
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions tools/perf/tests/perf-time-to-tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "tsc.h"
#include "mmap.h"
#include "tests.h"
#include "pmu.h"
#include "pmu-hybrid.h"

/*
* Except x86_64/i386 and Arm64, other archs don't support TSC in perf. Just
Expand Down Expand Up @@ -106,18 +104,8 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su

evlist__config(evlist, &opts, NULL);

evsel = evlist__first(evlist);

evsel->core.attr.comm = 1;
evsel->core.attr.disabled = 1;
evsel->core.attr.enable_on_exec = 0;

/*
* For hybrid "cycles:u", it creates two events.
* Init the second evsel here.
*/
if (perf_pmu__has_hybrid() && perf_pmu__hybrid_mounted("cpu_atom")) {
evsel = evsel__next(evsel);
/* For hybrid "cycles:u", it creates two events */
evlist__for_each_entry(evlist, evsel) {
evsel->core.attr.comm = 1;
evsel->core.attr.disabled = 1;
evsel->core.attr.enable_on_exec = 0;
Expand Down Expand Up @@ -170,10 +158,12 @@ static int test__perf_time_to_tsc(struct test_suite *test __maybe_unused, int su
goto next_event;

if (strcmp(event->comm.comm, comm1) == 0) {
CHECK_NOT_NULL__(evsel = evlist__event2evsel(evlist, event));
CHECK__(evsel__parse_sample(evsel, event, &sample));
comm1_time = sample.time;
}
if (strcmp(event->comm.comm, comm2) == 0) {
CHECK_NOT_NULL__(evsel = evlist__event2evsel(evlist, event));
CHECK__(evsel__parse_sample(evsel, event, &sample));
comm2_time = sample.time;
}
Expand Down

0 comments on commit deb44a6

Please sign in to comment.