perf x86 test: Add hybrid test for conflicting legacy/sysfs event
authorIan Rogers <irogers@google.com>
Wed, 3 Jan 2024 17:01:59 +0000 (09:01 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 3 Jan 2024 20:55:01 +0000 (17:55 -0300)
The cpu-cycles event is both a legacy event and declared in
/sys/devices/cpu_core/events/cpu-cycles. The cycles event is a legacy
event but with no sysfs version.

Add a test that the sysfs version is preferred to the legacy for
cpu-cycles, while for cycles we use the legacy version.

Suggested-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240103170159.1435753-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/arch/x86/tests/hybrid.c

index 05a5f81e81671782b0b70f07b354b0d9f8894fd6..40f5d17fedab6955c89042837eddb13227b04c58 100644 (file)
@@ -163,6 +163,24 @@ static int test__checkevent_pmu(struct evlist *evlist)
        return TEST_OK;
 }
 
+static int test__hybrid_hw_group_event_2(struct evlist *evlist)
+{
+       struct evsel *evsel, *leader;
+
+       evsel = leader = evlist__first(evlist);
+       TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
+       TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
+       TEST_ASSERT_VAL("wrong hybrid type", test_hybrid_type(evsel, PERF_TYPE_RAW));
+       TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
+       TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
+
+       evsel = evsel__next(evsel);
+       TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
+       TEST_ASSERT_VAL("wrong config", evsel->core.attr.config == 0x3c);
+       TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
+       return TEST_OK;
+}
+
 struct evlist_test {
        const char *name;
        bool (*valid)(void);
@@ -215,6 +233,11 @@ static const struct evlist_test test__hybrid_events[] = {
                .check = test__hybrid_cache_event,
                /* 8 */
        },
+       {
+               .name  = "{cpu_core/cycles/,cpu_core/cpu-cycles/}",
+               .check = test__hybrid_hw_group_event_2,
+               /* 9 */
+       },
 };
 
 static int test_event(const struct evlist_test *e)