From nobody Thu Oct 2 04:47:03 2025 Received: from mail-oa1-f73.google.com (mail-oa1-f73.google.com [209.85.160.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 528FE2D6E69 for ; Tue, 23 Sep 2025 04:19:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758601180; cv=none; b=FLaI3fPPPcLmKw+fGEXx1EdKh+dkK1HZaLYw4SpjKNMa2CaxBBDfy1u903F+HVcR70uZ/9bIcxD723hRe3Zil8gzkKdBnAICydvwWGwwtam9mJDo88/fwS6gQGhTlBaRUKgpc3plRVhL4ppaSGbbk06+nCqocOnkHQpYplBUqTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758601180; c=relaxed/simple; bh=sMXibGAMylnnOTr9IMrkloBsHRo/TuSst+eik782LGg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=uydLElAOmZNJ7n0UZPHHsGNtEvVwrJ1/3hFiUFGZljGKWB4GkCHEvq9Bd0v/ZlsgK7/aPX+SkWbs0lk/4LgNM3ZKdGK3DLs9MJrw0J8dNpWUrm3Ybk4h90LwV0ZLCurPV0ATBQaGokUrfN3l6+yLehYoyCVbLGYbcuGnxfcmyi4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=05KHM8S7; arc=none smtp.client-ip=209.85.160.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="05KHM8S7" Received: by mail-oa1-f73.google.com with SMTP id 586e51a60fabf-30cce517292so2286817fac.0 for ; Mon, 22 Sep 2025 21:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1758601177; x=1759205977; darn=vger.kernel.org; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=PFehdj+GFPwFMTY63Me6tuRq8q+VYWjAfL7ANtjBHOA=; b=05KHM8S7us08NtsYcAvNtor8hS1fMD1mjN1x1UB3vbyFRIJ35qxxox68r/aIMNRZ1D NEwg5XC0bdxc5anMIoN+qc9WVEdH75V6wCZzu6RqYg1tuW7zODqhZYnRzG5ajbQYpd+C Vud8qw0PmF0m3TbmEpw5edhELfhNR+RaQcSwjQr4LhuNFuv7PIlZJHIZiYF8KakqIOkh L4D7/vuXobXLp9cBg1xTf3V+xoDcxD5OGzhkMd0v6BB2y+vx9MKSzWe8FuvghFx7I0u/ Y4mEL+BudG13dNfqkvJaXkDOTLvS6BNRbXBLTpHSfr49eQvSgnWDPi6ocXt72065PYas wqew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758601177; x=1759205977; h=to:from:subject:message-id:references:mime-version:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PFehdj+GFPwFMTY63Me6tuRq8q+VYWjAfL7ANtjBHOA=; b=PTZqtdXL5E1kUP1fjHGLsz9gUAjUqMz9nIkLLilYVg5hYl5Lo+SeDoLLBnI9uCE1Ew bRvZJEH0K0osIOvcFZVHubt3ldBoIV2qh210dYE8tttvy2UX0AMsCX4yKlFTo4WHdnaf Omin1dIj4gYc+UfwWjEX1kouiOduJEbOrqnVPQfKnv/L5EJXm66RYqiat6DcnAqOpPOg eXtGNKmORGvxVUpDeSyyEHZVtOfDZc6L42Ovr1O2s7pAbGO7XAeyK50UVyYh5QabBf6/ 0AVtN7R35WYi/JtycXR2T73+WJQmg7S8ICqbUJwXUOb1ks6xC5k/rePsXClHwDiBPx3D bSlw== X-Forwarded-Encrypted: i=1; AJvYcCXlIPuAum3Qe0B/7If9x/NFdTi9yGKYcPiPB2Nv37U7sJhR8IYkASXzGfEt5KouIgVpOJB884p5So7RWdk=@vger.kernel.org X-Gm-Message-State: AOJu0YwcQHkVhpwDGLWISO/SNED510Ks0ooD6/uxsQ1+qGQs7/iz2Pp3 r0iyi/qt9ziSP66LE0a1zEOmWLoCtl8Vlg4AjSv2HvEIEyMNwZelHcsSqXH6lda9CGyNoUn8Ddl h6ZIUaIVVNw== X-Google-Smtp-Source: AGHT+IFYJLWg6R+xLesrlcZ26KCcGDTtIACNtv/0PFx/jnIGt+Kn4yXN+9qBD5mhLVmYTjEszZizeuu7MQZH X-Received: from oabpu26.prod.google.com ([2002:a05:6870:9e9a:b0:31d:67f5:36cc]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6870:6b97:b0:337:74c4:8f18 with SMTP id 586e51a60fabf-34c77660addmr625318fac.6.1758601177537; Mon, 22 Sep 2025 21:19:37 -0700 (PDT) Date: Mon, 22 Sep 2025 21:18:41 -0700 In-Reply-To: <20250923041844.400164-1-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250923041844.400164-1-irogers@google.com> X-Mailer: git-send-email 2.51.0.534.gc79095c0ca-goog Message-ID: <20250923041844.400164-23-irogers@google.com> Subject: [PATCH v5 22/25] perf test parse-events: Remove cpu PMU requirement From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Xu Yang , Thomas Falcon , Andi Kleen , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org, Atish Patra , Beeman Strong , Leo Yan , Vince Weaver Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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-event= s.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 *evlis= t) static int test__checkevent_pmu_name(struct evlist *evlist) { struct evsel *evsel =3D evlist__first(evlist); + struct perf_pmu *core_pmu =3D perf_pmus__find_core_pmu(); + char buf[256]; =20 - /* cpu/config=3D1,name=3Dkrava/u */ + /* default_core/config=3D1,name=3Dkrava/u */ TEST_ASSERT_VAL("wrong number of entries", 2 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 1 =3D=3D evsel->core.attr.config); TEST_ASSERT_VAL("wrong name", evsel__name_is(evsel, "krava")); =20 - /* cpu/config=3D2/u" */ + /* default_core/config=3D2/u" */ evsel =3D evsel__next(evsel); TEST_ASSERT_VAL("wrong number of entries", 2 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 2 =3D=3D evsel->core.attr.config); - TEST_ASSERT_VAL("wrong name", evsel__name_is(evsel, "cpu/config=3D2/u")); + snprintf(buf, sizeof(buf), "%s/config=3D2/u", core_pmu->name); + TEST_ASSERT_VAL("wrong name", evsel__name_is(evsel, buf)); =20 return TEST_OK; } @@ -667,7 +670,7 @@ static int test__checkevent_pmu_partial_time_callgraph(= struct evlist *evlist) { struct evsel *evsel =3D evlist__first(evlist); =20 - /* cpu/config=3D1,call-graph=3Dfp,time,period=3D100000/ */ + /* default_core/config=3D1,call-graph=3Dfp,time,period=3D100000/ */ TEST_ASSERT_VAL("wrong number of entries", 2 =3D=3D evlist->core.nr_entri= es); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 1 =3D=3D 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.samp= le_type)); =20 - /* cpu/config=3D2,call-graph=3Dno,time=3D0,period=3D2000/ */ + /* default_core/config=3D2,call-graph=3Dno,time=3D0,period=3D2000/ */ evsel =3D evsel__next(evsel); TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D evsel->core.attr.type); TEST_ASSERT_VAL("wrong config", 2 =3D=3D evsel->core.attr.config); @@ -702,7 +705,8 @@ static int test__checkevent_pmu_events(struct evlist *e= vlist) =20 evlist__for_each_entry(evlist, evsel) { TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW =3D=3D 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 evlis= t *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 =3D 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 evli= st *evlist) return test__checkevent_genhw(evlist); } =20 -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 =3D perf_pmus__find("cpu"); + struct perf_pmu *pmu =3D perf_pmus__find_core_pmu(); =20 if (!pmu) return false; @@ -2103,26 +2102,23 @@ static const struct evlist_test test__events[] =3D { =20 static const struct evlist_test test__events_pmu[] =3D { { - .name =3D "cpu/config=3D10,config1=3D1,config2=3D3,period=3D1000/u", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/config=3D10,config1=3D1,config2=3D3,period=3D10= 00/u", .check =3D test__checkevent_pmu, /* 0 */ }, { - .name =3D "cpu/config=3D1,name=3Dkrava/u,cpu/config=3D2/u", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/config=3D1,name=3Dkrava/u,default_core/config= =3D2/u", .check =3D test__checkevent_pmu_name, /* 1 */ }, { - .name =3D "cpu/config=3D1,call-graph=3Dfp,time,period=3D100000/,cpu/con= fig=3D2,call-graph=3Dno,time=3D0,period=3D2000/", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/config=3D1,call-graph=3Dfp,time,period=3D100000= /,default_core/config=3D2,call-graph=3Dno,time=3D0,period=3D2000/", .check =3D test__checkevent_pmu_partial_time_callgraph, /* 2 */ }, { - .name =3D "cpu/name=3D'COMPLEX_CYCLES_NAME:orig=3Dcycles,desc=3Dchip-cl= ock-ticks',period=3D0x1,event=3D0x2/ukp", - .valid =3D test__pmu_cpu_event_valid, + .name =3D "default_core/name=3D'COMPLEX_CYCLES_NAME:orig=3Dcycles,desc= =3Dchip-clock-ticks',period=3D0x1,event=3D0x2/ukp", + .valid =3D test__pmu_default_core_event_valid, .check =3D test__checkevent_complex_name, /* 3 */ }, @@ -2137,158 +2133,132 @@ static const struct evlist_test test__events_pmu[= ] =3D { /* 5 */ }, { - .name =3D "cpu/L1-dcache-load-miss/", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/L1-dcache-load-miss/", .check =3D test__checkevent_genhw, /* 6 */ }, { - .name =3D "cpu/L1-dcache-load-miss/kp", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/L1-dcache-load-miss/kp", .check =3D test__checkevent_genhw_modifier, /* 7 */ }, { - .name =3D "cpu/L1-dcache-misses,name=3Dcachepmu/", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/L1-dcache-misses,name=3Dcachepmu/", .check =3D test__checkevent_config_cache, /* 8 */ }, { - .name =3D "cpu/instructions/", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/instructions/", .check =3D test__checkevent_symbolic_name, /* 9 */ }, { - .name =3D "cpu/cycles,period=3D100000,config2/", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/cycles,period=3D100000,config2/", .check =3D test__checkevent_symbolic_name_config, /* 0 */ }, { - .name =3D "cpu/instructions/h", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/instructions/h", .check =3D test__checkevent_symbolic_name_modifier, /* 1 */ }, { - .name =3D "cpu/instructions/G", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/instructions/G", .check =3D test__checkevent_exclude_host_modifier, /* 2 */ }, { - .name =3D "cpu/instructions/H", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/instructions/H", .check =3D test__checkevent_exclude_guest_modifier, /* 3 */ }, { - .name =3D "{cpu/instructions/k,cpu/cycles/upp}", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/instructions/k,default_core/cycles/upp}", .check =3D test__group1, /* 4 */ }, { - .name =3D "{cpu/cycles/u,cpu/instructions/kp}:p", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/cycles/u,default_core/instructions/kp}:p", .check =3D test__group4, /* 5 */ }, { - .name =3D "{cpu/cycles/,cpu/cache-misses/G}:H", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/cycles/,default_core/cache-misses/G}:H", .check =3D test__group_gh1, /* 6 */ }, { - .name =3D "{cpu/cycles/,cpu/cache-misses/H}:G", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/cycles/,default_core/cache-misses/H}:G", .check =3D test__group_gh2, /* 7 */ }, { - .name =3D "{cpu/cycles/G,cpu/cache-misses/H}:u", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/cycles/G,default_core/cache-misses/H}:u", .check =3D test__group_gh3, /* 8 */ }, { - .name =3D "{cpu/cycles/G,cpu/cache-misses/H}:uG", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/cycles/G,default_core/cache-misses/H}:uG", .check =3D test__group_gh4, /* 9 */ }, { - .name =3D "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:S", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/cycles/,default_core/cache-misses/,default_cor= e/branch-misses/}:S", .check =3D test__leader_sample1, /* 0 */ }, { - .name =3D "{cpu/instructions/,cpu/branch-misses/}:Su", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/instructions/,default_core/branch-misses/}:Su", .check =3D test__leader_sample2, /* 1 */ }, { - .name =3D "cpu/instructions/uDp", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/instructions/uDp", .check =3D test__checkevent_pinned_modifier, /* 2 */ }, { - .name =3D "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:D", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/cycles/,default_core/cache-misses/,default_cor= e/branch-misses/}:D", .check =3D test__pinned_group, /* 3 */ }, { - .name =3D "cpu/instructions/I", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/instructions/I", .check =3D test__checkevent_exclude_idle_modifier, /* 4 */ }, { - .name =3D "cpu/instructions/kIG", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/instructions/kIG", .check =3D test__checkevent_exclude_idle_modifier_1, /* 5 */ }, { - .name =3D "cpu/cycles/u", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/cycles/u", .check =3D test__sym_event_slash, /* 6 */ }, { - .name =3D "cpu/cycles/k", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/cycles/k", .check =3D test__sym_event_dc, /* 7 */ }, { - .name =3D "cpu/instructions/uep", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/instructions/uep", .check =3D test__checkevent_exclusive_modifier, /* 8 */ }, { - .name =3D "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:e", - .valid =3D test__pmu_cpu_valid, + .name =3D "{default_core/cycles/,default_core/cache-misses/,default_cor= e/branch-misses/}:e", .check =3D test__exclusive_group, /* 9 */ }, { - .name =3D "cpu/cycles,name=3Dname/", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/cycles,name=3Dname/", .check =3D test__term_equal_term, /* 0 */ }, { - .name =3D "cpu/cycles,name=3Dl1d/", - .valid =3D test__pmu_cpu_valid, + .name =3D "default_core/cycles,name=3Dl1d/", .check =3D test__term_equal_legacy, /* 1 */ }, @@ -2378,15 +2348,30 @@ static int combine_test_results(int existing, int l= atest) static int test_events(const struct evlist_test *events, int cnt) { int ret =3D TEST_OK; + struct perf_pmu *core_pmu =3D perf_pmus__find_core_pmu(); =20 for (int i =3D 0; i < cnt; i++) { - const struct evlist_test *e =3D &events[i]; + struct evlist_test e =3D events[i]; int test_ret; + const char *pos =3D e.name; + char buf[1024], *buf_pos =3D buf, *end; + + while ((end =3D strstr(pos, "default_core"))) { + size_t len =3D end - pos; + + strncpy(buf_pos, pos, len); + pos =3D end + 12; + buf_pos +=3D len; + strcpy(buf_pos, core_pmu->name); + buf_pos +=3D strlen(core_pmu->name); + } + strcpy(buf_pos, pos); =20 - pr_debug("running test %d '%s'\n", i, e->name); - test_ret =3D test_event(e); + e.name =3D buf; + pr_debug("running test %d '%s'\n", i, e.name); + test_ret =3D test_event(&e); if (test_ret !=3D 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 =3D combine_test_results(ret, test_ret); } } --=20 2.51.0.534.gc79095c0ca-goog