summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJames Clark <james.clark@arm.com>2023-07-05 09:26:52 +0100
committerNamhyung Kim <namhyung@kernel.org>2023-07-05 12:23:00 -0700
commitbcd981db12e6d26111609802fc7c358f30a8c72a (patch)
tree4b04cddb1cab021c2f63470ef1b04dab2f6b22c3 /tools
parent808ce56e7d6bfc144b18ded8c11819c45a889520 (diff)
perf test: Fix event parsing test when PERF_PMU_CAP_EXTENDED_HW_TYPE isn't supported.
Arm has multiple PMU types for heterogeneous systems, but doesn't currently support PERF_PMU_CAP_EXTENDED_HW_TYPE. Make the tests support both scenarios so that they pass on Arm, and will still pass once PERF_PMU_CAP_EXTENDED_HW_TYPE support is added. Fixes: 27c9fcfc1e14 ("perf test: Update parse-events expectations to test for multiple events") Acked-by: Ian Rogers <irogers@google.com> Signed-off-by: James Clark <james.clark@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ingo Molnar <mingo@redhat.com> Link: https://lore.kernel.org/r/20230705082653.23566-3-james.clark@arm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/tests/parse-events.c86
1 files changed, 50 insertions, 36 deletions
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 21f79aa31233..b2f82847e4c3 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -20,6 +20,20 @@
#define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
+static int num_core_entries(void)
+{
+ /*
+ * If the kernel supports extended type, expect events to be
+ * opened once for each core PMU type. Otherwise fall back to the legacy
+ * behavior of opening only one event even though there are multiple
+ * PMUs
+ */
+ if (perf_pmus__supports_extended_type())
+ return perf_pmus__num_core_pmus();
+
+ return 1;
+}
+
static bool test_config(const struct evsel *evsel, __u64 expected_config)
{
__u32 type = evsel->core.attr.type;
@@ -339,7 +353,7 @@ static int test__checkevent_symbolic_name_modifier(struct evlist *evlist)
struct perf_evsel *evsel;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == perf_pmus__num_core_pmus());
+ evlist->core.nr_entries == num_core_entries());
perf_evlist__for_each_entry(&evlist->core, evsel) {
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
@@ -842,11 +856,11 @@ static int test__group1(struct evlist *evlist)
struct evsel *evsel, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (perf_pmus__num_core_pmus() * 2));
+ evlist->core.nr_entries == (num_core_entries() * 2));
TEST_ASSERT_VAL("wrong number of groups",
- evlist__nr_groups(evlist) == perf_pmus__num_core_pmus());
+ evlist__nr_groups(evlist) == num_core_entries());
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* instructions:k */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -885,7 +899,7 @@ static int test__group2(struct evlist *evlist)
struct evsel *evsel, *leader = NULL;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus() + 1));
+ evlist->core.nr_entries == (2 * num_core_entries() + 1));
/*
* TODO: Currently the software event won't be grouped with the hardware
* event except for 1 PMU.
@@ -1051,11 +1065,11 @@ static int test__group4(struct evlist *evlist __maybe_unused)
struct evsel *evsel, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (perf_pmus__num_core_pmus() * 2));
+ evlist->core.nr_entries == (num_core_entries() * 2));
TEST_ASSERT_VAL("wrong number of groups",
- perf_pmus__num_core_pmus() == evlist__nr_groups(evlist));
+ num_core_entries() == evlist__nr_groups(evlist));
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles:u + p */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1096,11 +1110,11 @@ static int test__group5(struct evlist *evlist __maybe_unused)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (5 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == (5 * num_core_entries()));
TEST_ASSERT_VAL("wrong number of groups",
- evlist__nr_groups(evlist) == (2 * perf_pmus__num_core_pmus()));
+ evlist__nr_groups(evlist) == (2 * num_core_entries()));
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles + G */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1131,7 +1145,7 @@ static int test__group5(struct evlist *evlist __maybe_unused)
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
}
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles:G */
evsel = leader = evsel__next(evsel);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1161,7 +1175,7 @@ static int test__group5(struct evlist *evlist __maybe_unused)
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
}
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles */
evsel = evsel__next(evsel);
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1182,11 +1196,11 @@ static int test__group_gh1(struct evlist *evlist)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == (2 * num_core_entries()));
TEST_ASSERT_VAL("wrong number of groups",
- evlist__nr_groups(evlist) == perf_pmus__num_core_pmus());
+ evlist__nr_groups(evlist) == num_core_entries());
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles + :H group modifier */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1223,11 +1237,11 @@ static int test__group_gh2(struct evlist *evlist)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == (2 * num_core_entries()));
TEST_ASSERT_VAL("wrong number of groups",
- evlist__nr_groups(evlist) == perf_pmus__num_core_pmus());
+ evlist__nr_groups(evlist) == num_core_entries());
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles + :G group modifier */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1264,11 +1278,11 @@ static int test__group_gh3(struct evlist *evlist)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == (2 * num_core_entries()));
TEST_ASSERT_VAL("wrong number of groups",
- evlist__nr_groups(evlist) == perf_pmus__num_core_pmus());
+ evlist__nr_groups(evlist) == num_core_entries());
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles:G + :u group modifier */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1305,11 +1319,11 @@ static int test__group_gh4(struct evlist *evlist)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == (2 * num_core_entries()));
TEST_ASSERT_VAL("wrong number of groups",
- evlist__nr_groups(evlist) == perf_pmus__num_core_pmus());
+ evlist__nr_groups(evlist) == num_core_entries());
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles:G + :uG group modifier */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1346,9 +1360,9 @@ static int test__leader_sample1(struct evlist *evlist)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (3 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == (3 * num_core_entries()));
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles - sampling group leader */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1398,9 +1412,9 @@ static int test__leader_sample2(struct evlist *evlist __maybe_unused)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (2 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == (2 * num_core_entries()));
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* instructions - sampling group leader */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1437,9 +1451,9 @@ static int test__checkevent_pinned_modifier(struct evlist *evlist)
struct evsel *evsel = NULL;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == perf_pmus__num_core_pmus());
+ evlist->core.nr_entries == num_core_entries());
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
evsel = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -1455,9 +1469,9 @@ static int test__pinned_group(struct evlist *evlist)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (3 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == (3 * num_core_entries()));
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles - group leader */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1500,9 +1514,9 @@ static int test__exclusive_group(struct evlist *evlist)
struct evsel *evsel = NULL, *leader;
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (3 * perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == 3 * num_core_entries());
- for (int i = 0; i < perf_pmus__num_core_pmus(); i++) {
+ for (int i = 0; i < num_core_entries(); i++) {
/* cycles - group leader */
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
@@ -1574,7 +1588,7 @@ static int test__checkevent_precise_max_modifier(struct evlist *evlist)
struct evsel *evsel = evlist__first(evlist);
TEST_ASSERT_VAL("wrong number of entries",
- evlist->core.nr_entries == (1 + perf_pmus__num_core_pmus()));
+ evlist->core.nr_entries == 1 + num_core_entries());
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_SW_TASK_CLOCK));
return TEST_OK;