[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAP-5=fUvDoyMW2pu-f4-Qoxr6RX_k2+NZ4STmeSDQRFyhvN89g@mail.gmail.com>
Date: Tue, 23 Sep 2025 08:52:53 -0700
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>, James Clark <james.clark@...aro.org>,
Xu Yang <xu.yang_2@....com>, Thomas Falcon <thomas.falcon@...el.com>,
Andi Kleen <ak@...ux.intel.com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, bpf@...r.kernel.org,
Atish Patra <atishp@...osinc.com>, Beeman Strong <beeman@...osinc.com>, Leo Yan <leo.yan@....com>,
Vince Weaver <vincent.weaver@...ne.edu>
Subject: Re: [PATCH v5 22/25] perf test parse-events: Remove cpu PMU requirement
On Mon, Sep 22, 2025 at 9:19 PM Ian Rogers <irogers@...gle.com> wrote:
>
> In the event parse string, switch "cpu" to "default_core" and then
> rewrite this to the first core PMU name prior to parsing. This enables
> testing with a PMU on hybrid x86 and other systems that don't use
> "cpu" for the core PMU name. The name "default_core" is already used
> by jevents. Update test expectations to match.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>
This introduces a test failure on Intel hybrid that I'll fix in v6.
Previously the failing tests weren't run and the test expectation was
that, with a PMU or without a PMU, an event would be opened on all
PMUs - which isn't true if the PMU is specified.
Thanks,
Ian
> ---
> tools/perf/tests/parse-events.c | 141 ++++++++++++++------------------
> 1 file changed, 63 insertions(+), 78 deletions(-)
>
> diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
> index d0f1e05139ac..4f197f34621b 100644
> --- a/tools/perf/tests/parse-events.c
> +++ b/tools/perf/tests/parse-events.c
> @@ -646,19 +646,22 @@ static int test__checkevent_list(struct evlist *evlist)
> static int test__checkevent_pmu_name(struct evlist *evlist)
> {
> struct evsel *evsel = evlist__first(evlist);
> + struct perf_pmu *core_pmu = perf_pmus__find_core_pmu();
> + char buf[256];
>
> - /* cpu/config=1,name=krava/u */
> + /* default_core/config=1,name=krava/u */
> TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
> TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
> TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
> TEST_ASSERT_VAL("wrong name", evsel__name_is(evsel, "krava"));
>
> - /* cpu/config=2/u" */
> + /* default_core/config=2/u" */
> evsel = evsel__next(evsel);
> TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
> TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
> TEST_ASSERT_VAL("wrong config", 2 == evsel->core.attr.config);
> - TEST_ASSERT_VAL("wrong name", evsel__name_is(evsel, "cpu/config=2/u"));
> + snprintf(buf, sizeof(buf), "%s/config=2/u", core_pmu->name);
> + TEST_ASSERT_VAL("wrong name", evsel__name_is(evsel, buf));
>
> return TEST_OK;
> }
> @@ -667,7 +670,7 @@ static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
> {
> struct evsel *evsel = evlist__first(evlist);
>
> - /* cpu/config=1,call-graph=fp,time,period=100000/ */
> + /* default_core/config=1,call-graph=fp,time,period=100000/ */
> TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
> TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
> TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
> @@ -679,7 +682,7 @@ static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
> TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
> TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
>
> - /* cpu/config=2,call-graph=no,time=0,period=2000/ */
> + /* default_core/config=2,call-graph=no,time=0,period=2000/ */
> evsel = evsel__next(evsel);
> TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
> TEST_ASSERT_VAL("wrong config", 2 == evsel->core.attr.config);
> @@ -702,7 +705,8 @@ static int test__checkevent_pmu_events(struct evlist *evlist)
>
> evlist__for_each_entry(evlist, evsel) {
> TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type ||
> - strcmp(evsel->pmu->name, "cpu"));
> + !strncmp(evsel__name(evsel), evsel->pmu->name,
> + strlen(evsel->pmu->name)));
> TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
> TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
> TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
> @@ -735,7 +739,7 @@ static int test__checkevent_pmu_events_mix(struct evlist *evlist)
> TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
> TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
> }
> - /* cpu/pmu-event/u*/
> + /* default_core/pmu-event/u*/
> evsel = evsel__next(evsel);
> TEST_ASSERT_VAL("wrong type", evsel__find_pmu(evsel)->is_core);
> TEST_ASSERT_VAL("wrong exclude_user",
> @@ -1570,14 +1574,9 @@ static int test__checkevent_config_cache(struct evlist *evlist)
> return test__checkevent_genhw(evlist);
> }
>
> -static bool test__pmu_cpu_valid(void)
> +static bool test__pmu_default_core_event_valid(void)
> {
> - return !!perf_pmus__find("cpu");
> -}
> -
> -static bool test__pmu_cpu_event_valid(void)
> -{
> - struct perf_pmu *pmu = perf_pmus__find("cpu");
> + struct perf_pmu *pmu = perf_pmus__find_core_pmu();
>
> if (!pmu)
> return false;
> @@ -2103,26 +2102,23 @@ static const struct evlist_test test__events[] = {
>
> static const struct evlist_test test__events_pmu[] = {
> {
> - .name = "cpu/config=10,config1=1,config2=3,period=1000/u",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/config=10,config1=1,config2=3,period=1000/u",
> .check = test__checkevent_pmu,
> /* 0 */
> },
> {
> - .name = "cpu/config=1,name=krava/u,cpu/config=2/u",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/config=1,name=krava/u,default_core/config=2/u",
> .check = test__checkevent_pmu_name,
> /* 1 */
> },
> {
> - .name = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/config=1,call-graph=fp,time,period=100000/,default_core/config=2,call-graph=no,time=0,period=2000/",
> .check = test__checkevent_pmu_partial_time_callgraph,
> /* 2 */
> },
> {
> - .name = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
> - .valid = test__pmu_cpu_event_valid,
> + .name = "default_core/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
> + .valid = test__pmu_default_core_event_valid,
> .check = test__checkevent_complex_name,
> /* 3 */
> },
> @@ -2137,158 +2133,132 @@ static const struct evlist_test test__events_pmu[] = {
> /* 5 */
> },
> {
> - .name = "cpu/L1-dcache-load-miss/",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/L1-dcache-load-miss/",
> .check = test__checkevent_genhw,
> /* 6 */
> },
> {
> - .name = "cpu/L1-dcache-load-miss/kp",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/L1-dcache-load-miss/kp",
> .check = test__checkevent_genhw_modifier,
> /* 7 */
> },
> {
> - .name = "cpu/L1-dcache-misses,name=cachepmu/",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/L1-dcache-misses,name=cachepmu/",
> .check = test__checkevent_config_cache,
> /* 8 */
> },
> {
> - .name = "cpu/instructions/",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/instructions/",
> .check = test__checkevent_symbolic_name,
> /* 9 */
> },
> {
> - .name = "cpu/cycles,period=100000,config2/",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/cycles,period=100000,config2/",
> .check = test__checkevent_symbolic_name_config,
> /* 0 */
> },
> {
> - .name = "cpu/instructions/h",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/instructions/h",
> .check = test__checkevent_symbolic_name_modifier,
> /* 1 */
> },
> {
> - .name = "cpu/instructions/G",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/instructions/G",
> .check = test__checkevent_exclude_host_modifier,
> /* 2 */
> },
> {
> - .name = "cpu/instructions/H",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/instructions/H",
> .check = test__checkevent_exclude_guest_modifier,
> /* 3 */
> },
> {
> - .name = "{cpu/instructions/k,cpu/cycles/upp}",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/instructions/k,default_core/cycles/upp}",
> .check = test__group1,
> /* 4 */
> },
> {
> - .name = "{cpu/cycles/u,cpu/instructions/kp}:p",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/cycles/u,default_core/instructions/kp}:p",
> .check = test__group4,
> /* 5 */
> },
> {
> - .name = "{cpu/cycles/,cpu/cache-misses/G}:H",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/cycles/,default_core/cache-misses/G}:H",
> .check = test__group_gh1,
> /* 6 */
> },
> {
> - .name = "{cpu/cycles/,cpu/cache-misses/H}:G",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/cycles/,default_core/cache-misses/H}:G",
> .check = test__group_gh2,
> /* 7 */
> },
> {
> - .name = "{cpu/cycles/G,cpu/cache-misses/H}:u",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/cycles/G,default_core/cache-misses/H}:u",
> .check = test__group_gh3,
> /* 8 */
> },
> {
> - .name = "{cpu/cycles/G,cpu/cache-misses/H}:uG",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/cycles/G,default_core/cache-misses/H}:uG",
> .check = test__group_gh4,
> /* 9 */
> },
> {
> - .name = "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:S",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/cycles/,default_core/cache-misses/,default_core/branch-misses/}:S",
> .check = test__leader_sample1,
> /* 0 */
> },
> {
> - .name = "{cpu/instructions/,cpu/branch-misses/}:Su",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/instructions/,default_core/branch-misses/}:Su",
> .check = test__leader_sample2,
> /* 1 */
> },
> {
> - .name = "cpu/instructions/uDp",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/instructions/uDp",
> .check = test__checkevent_pinned_modifier,
> /* 2 */
> },
> {
> - .name = "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:D",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/cycles/,default_core/cache-misses/,default_core/branch-misses/}:D",
> .check = test__pinned_group,
> /* 3 */
> },
> {
> - .name = "cpu/instructions/I",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/instructions/I",
> .check = test__checkevent_exclude_idle_modifier,
> /* 4 */
> },
> {
> - .name = "cpu/instructions/kIG",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/instructions/kIG",
> .check = test__checkevent_exclude_idle_modifier_1,
> /* 5 */
> },
> {
> - .name = "cpu/cycles/u",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/cycles/u",
> .check = test__sym_event_slash,
> /* 6 */
> },
> {
> - .name = "cpu/cycles/k",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/cycles/k",
> .check = test__sym_event_dc,
> /* 7 */
> },
> {
> - .name = "cpu/instructions/uep",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/instructions/uep",
> .check = test__checkevent_exclusive_modifier,
> /* 8 */
> },
> {
> - .name = "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:e",
> - .valid = test__pmu_cpu_valid,
> + .name = "{default_core/cycles/,default_core/cache-misses/,default_core/branch-misses/}:e",
> .check = test__exclusive_group,
> /* 9 */
> },
> {
> - .name = "cpu/cycles,name=name/",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/cycles,name=name/",
> .check = test__term_equal_term,
> /* 0 */
> },
> {
> - .name = "cpu/cycles,name=l1d/",
> - .valid = test__pmu_cpu_valid,
> + .name = "default_core/cycles,name=l1d/",
> .check = test__term_equal_legacy,
> /* 1 */
> },
> @@ -2378,15 +2348,30 @@ static int combine_test_results(int existing, int latest)
> static int test_events(const struct evlist_test *events, int cnt)
> {
> int ret = TEST_OK;
> + struct perf_pmu *core_pmu = perf_pmus__find_core_pmu();
>
> for (int i = 0; i < cnt; i++) {
> - const struct evlist_test *e = &events[i];
> + struct evlist_test e = events[i];
> int test_ret;
> + const char *pos = e.name;
> + char buf[1024], *buf_pos = buf, *end;
> +
> + while ((end = strstr(pos, "default_core"))) {
> + size_t len = end - pos;
> +
> + strncpy(buf_pos, pos, len);
> + pos = end + 12;
> + buf_pos += len;
> + strcpy(buf_pos, core_pmu->name);
> + buf_pos += strlen(core_pmu->name);
> + }
> + strcpy(buf_pos, pos);
>
> - pr_debug("running test %d '%s'\n", i, e->name);
> - test_ret = test_event(e);
> + e.name = buf;
> + pr_debug("running test %d '%s'\n", i, e.name);
> + test_ret = test_event(&e);
> if (test_ret != TEST_OK) {
> - pr_debug("Event test failure: test %d '%s'", i, e->name);
> + pr_debug("Event test failure: test %d '%s'", i, e.name);
> ret = combine_test_results(ret, test_ret);
> }
> }
> --
> 2.51.0.534.gc79095c0ca-goog
>
Powered by blists - more mailing lists