From nobody Thu Oct 2 03:32:43 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 8535931D721 for ; Tue, 23 Sep 2025 22:34:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758666845; cv=none; b=c6CuF1cuvRLOgDvnlsUB/RRwx46WNahAwT4uOcu7CRIxt6DScRejOibi4XAsCwQGjNhsHC8HxuMQUUt8sY7kvx0P2j43U3uenL7PVtAIxqdlPOdRLbz0GacbLKXo9BemWojGTDHUaazDvbVWPDZwWJ0I1N0L/I2Cejp4elmMl18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758666845; c=relaxed/simple; bh=tiWZCYYxARhFlflX9gneYHYq1ndN45QYaRl9OxqYSss=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Content-Type; b=hIxoZumkyA9EGQ13u+mUlAm2PLKgBhE7XN7+i5NxLR8bqRlyxE5k0owSbmSgaM+tk98KF6HumL72te8rfxGpQOxCw24GpnkOhot5+BZ6ZlH1zv8zRiYYg981sCToD7gTMtccLY8HIfMGMaJuUNtsOYloJwvTM+Mvk1rhQFr6Vno= 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=V6O5bavI; arc=none smtp.client-ip=209.85.216.74 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="V6O5bavI" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-32eb2b284e4so9666582a91.1 for ; Tue, 23 Sep 2025 15:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1758666843; x=1759271643; 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=YAJoI+cyj2/WQZx/UQN66Kq9JhNBF6jZceW/gXQediQ=; b=V6O5bavIn/ONew0nb9ChhX0akcDWR5oGYWc2urzg6UAoSOeScAEk9KdPvr+oy1zvbE gVlgtOW/nyEV3Bm+3Xl2iMjSM+6q5y+YQEx4r/pG8FkYooup+84xJsN2fdFIWNnm1bI3 8WHq+qkqYOQDmR7teTQkLa6ErqtpuHxiow0RdNxdEKB4b2roebPgWi31colqJa7gN2co CTEzkD3kyOEpIRf3b7q8NCSpkG5x+pKunccwadwLWkll8qLkLdDCtF2J0x0IN5ezPK8Z ytkt6udC1IieMi+fAEK6C+oC9mb+rF5fqWqbDXwpzXnM2J73WeLr9GWjlX+IA2KcNClN FGwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758666843; x=1759271643; 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=YAJoI+cyj2/WQZx/UQN66Kq9JhNBF6jZceW/gXQediQ=; b=MWAQ16UkpsAv9w7P+Ijel7lVV70p8i+bxPrBB9Xe1HcCy3eBJ/y7bN4fLJTSzvvTMG wRMexIT+nXF54IC4atI3C/dd5FGt1W8iiCy0ATHVAOCh2iKJE+YoJaw9cnFrjD1AQC9O ggxZQAq2y43C4+o9GwehOB96oCoeL8+j+5v8/HzxWBWyDLtDNIcxPKTsGNMJrOhFmbpl FlJ9a+DGP4Eniu0i2w+G2SslTnCmaEhxBdo+t6Hp9QY9rC4XdmNd8bI0/QBox+LfS2eh gf0iJoF+eaulQqF9H9Q0wuE3al2UH4I29Fz+CWVr2dvaNlXuj8mroSq4GXb/36ng6dK9 KC5w== X-Forwarded-Encrypted: i=1; AJvYcCW064w4wFPEQYsz2yU+Gq+EenTMcOHe54luG/KBm1xRflrF7WNjR4ZtOikaFlWg7/YXk0PEAr8+fSp7NxE=@vger.kernel.org X-Gm-Message-State: AOJu0YwzofXQtArT5ElqpQQTU0nyiOAWvjrQc8mN4ZZXmEVT4Sfq3oIj +sqxY/8CA5GudlQZE7jCeHH9+0TTNRbvzK8A6AHSHlsMul2LD1HTkI8ehJTQerx20UIt9Itat9d 1b2c8+4qUgg== X-Google-Smtp-Source: AGHT+IGW2+etZYDdjrmmVI9zDIVzK4Ak2FxXUmMiPP/1sV7xNBhsKnRImqMfzxq0a83LUqEMjCQoJUossTvX X-Received: from pjbta8.prod.google.com ([2002:a17:90b:4ec8:b0:330:6513:c709]) (user=irogers job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:33c8:b0:32d:f4cb:7486 with SMTP id 98e67ed59e1d1-332a95e8e19mr4862342a91.19.1758666842731; Tue, 23 Sep 2025 15:34:02 -0700 (PDT) Date: Tue, 23 Sep 2025 15:33:07 -0700 In-Reply-To: <20250923223312.238185-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: <20250923223312.238185-1-irogers@google.com> X-Mailer: git-send-email 2.51.0.534.gc79095c0ca-goog Message-ID: <20250923223312.238185-24-irogers@google.com> Subject: [PATCH v6 23/28] perf test parse-events: Without a PMU use cpu-cycles rather than cycles 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, Atish Patra , Beeman Strong , Leo Yan , Vince Weaver Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Without a PMU perf matches an event against any PMU with the event. Unfortunately some PMU drivers advertise a "cycles" event which is typically just a core event. Switch to using "cpu-cycles" which is an indentical legacy event but avoids the multiple PMU confusion introduced by the PMU drivers. Note, on x86 cpu-cycles is also a sysfs event but cycles isn't. Signed-off-by: Ian Rogers --- tools/perf/tests/parse-events.c | 61 ++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index d0f1e05139ac..32981a1e4042 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -585,9 +585,10 @@ static int test__checkevent_pmu(struct evlist *evlist) { =20 struct evsel *evsel =3D evlist__first(evlist); + struct perf_pmu *core_pmu =3D perf_pmus__find_core_pmu(); =20 TEST_ASSERT_VAL("wrong number of entries", 1 =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 type", core_pmu->type =3D=3D evsel->core.attr.type= ); TEST_ASSERT_VAL("wrong config", test_config(evsel, 10)); TEST_ASSERT_VAL("wrong config1", 1 =3D=3D evsel->core.attr.config1); TEST_ASSERT_VAL("wrong config2", 3 =3D=3D evsel->core.attr.config2); @@ -646,17 +647,18 @@ 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(); =20 /* cpu/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 type", core_pmu->type =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" */ 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 type", core_pmu->type =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")); =20 @@ -666,10 +668,11 @@ static int test__checkevent_pmu_name(struct evlist *e= vlist) static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evli= st) { struct evsel *evsel =3D evlist__first(evlist); + struct perf_pmu *core_pmu =3D perf_pmus__find_core_pmu(); =20 /* cpu/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 type", core_pmu->type =3D=3D evsel->core.attr.type= ); TEST_ASSERT_VAL("wrong config", 1 =3D=3D evsel->core.attr.config); /* * The period, time and callgraph value gets configured within evlist__co= nfig, @@ -681,7 +684,7 @@ static int test__checkevent_pmu_partial_time_callgraph(= struct evlist *evlist) =20 /* cpu/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 type", core_pmu->type =3D=3D evsel->core.attr.type= ); TEST_ASSERT_VAL("wrong config", 2 =3D=3D evsel->core.attr.config); /* * The period, time and callgraph value gets configured within evlist__co= nfig, @@ -697,12 +700,14 @@ static int test__checkevent_pmu_partial_time_callgrap= h(struct evlist *evlist) static int test__checkevent_pmu_events(struct evlist *evlist) { struct evsel *evsel; + struct perf_pmu *core_pmu =3D perf_pmus__find_core_pmu(); =20 TEST_ASSERT_VAL("wrong number of entries", 1 <=3D evlist->core.nr_entries= ); =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")); + TEST_ASSERT_VAL("wrong type", core_pmu->type =3D=3D evsel->core.attr.typ= e || + !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); @@ -1604,7 +1609,7 @@ static int test__checkevent_complex_name(struct evlis= t *evlist) =20 TEST_ASSERT_VAL("wrong complex name parsing", evsel__name_is(evsel, - "COMPLEX_CYCLES_NAME:orig=3Dcycles,desc=3Dchip-clock-ticks")); + "COMPLEX_CYCLES_NAME:orig=3Dcpu-cycles,desc=3Dchip-clock-ticks"= )); return TEST_OK; } =20 @@ -1741,7 +1746,7 @@ static const struct evlist_test test__events[] =3D { /* 4 */ }, { - .name =3D "cycles/period=3D100000,config2/", + .name =3D "cpu-cycles/period=3D100000,config2/", .check =3D test__checkevent_symbolic_name_config, /* 5 */ }, @@ -1856,27 +1861,27 @@ static const struct evlist_test test__events[] =3D { /* 7 */ }, { - .name =3D "{instructions:k,cycles:upp}", + .name =3D "{instructions:k,cpu-cycles:upp}", .check =3D test__group1, /* 8 */ }, { - .name =3D "{faults:k,branches}:u,cycles:k", + .name =3D "{faults:k,branches}:u,cpu-cycles:k", .check =3D test__group2, /* 9 */ }, { - .name =3D "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycle= s,1:3}:G,instructions:u", + .name =3D "group1{syscalls:sys_enter_openat:H,cpu-cycles:kppp},group2{c= pu-cycles,1:3}:G,instructions:u", .check =3D test__group3, /* 0 */ }, { - .name =3D "{cycles:u,instructions:kp}:p", + .name =3D "{cpu-cycles:u,instructions:kp}:p", .check =3D test__group4, /* 1 */ }, { - .name =3D "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", + .name =3D "{cpu-cycles,instructions}:G,{cpu-cycles:G,instructions:G},cp= u-cycles", .check =3D test__group5, /* 2 */ }, @@ -1886,27 +1891,27 @@ static const struct evlist_test test__events[] =3D { /* 3 */ }, { - .name =3D "{cycles,cache-misses:G}:H", + .name =3D "{cpu-cycles,cache-misses:G}:H", .check =3D test__group_gh1, /* 4 */ }, { - .name =3D "{cycles,cache-misses:H}:G", + .name =3D "{cpu-cycles,cache-misses:H}:G", .check =3D test__group_gh2, /* 5 */ }, { - .name =3D "{cycles:G,cache-misses:H}:u", + .name =3D "{cpu-cycles:G,cache-misses:H}:u", .check =3D test__group_gh3, /* 6 */ }, { - .name =3D "{cycles:G,cache-misses:H}:uG", + .name =3D "{cpu-cycles:G,cache-misses:H}:uG", .check =3D test__group_gh4, /* 7 */ }, { - .name =3D "{cycles,cache-misses,branch-misses}:S", + .name =3D "{cpu-cycles,cache-misses,branch-misses}:S", .check =3D test__leader_sample1, /* 8 */ }, @@ -1921,7 +1926,7 @@ static const struct evlist_test test__events[] =3D { /* 0 */ }, { - .name =3D "{cycles,cache-misses,branch-misses}:D", + .name =3D "{cpu-cycles,cache-misses,branch-misses}:D", .check =3D test__pinned_group, /* 1 */ }, @@ -1959,7 +1964,7 @@ static const struct evlist_test test__events[] =3D { /* 6 */ }, { - .name =3D "task-clock:P,cycles", + .name =3D "task-clock:P,cpu-cycles", .check =3D test__checkevent_precise_max_modifier, /* 7 */ }, @@ -1990,17 +1995,17 @@ static const struct evlist_test test__events[] =3D { /* 2 */ }, { - .name =3D "cycles/name=3D'COMPLEX_CYCLES_NAME:orig=3Dcycles,desc=3Dchip= -clock-ticks'/Duk", + .name =3D "cpu-cycles/name=3D'COMPLEX_CYCLES_NAME:orig=3Dcpu-cycles,des= c=3Dchip-clock-ticks'/Duk", .check =3D test__checkevent_complex_name, /* 3 */ }, { - .name =3D "cycles//u", + .name =3D "cpu-cycles//u", .check =3D test__sym_event_slash, /* 4 */ }, { - .name =3D "cycles:k", + .name =3D "cpu-cycles:k", .check =3D test__sym_event_dc, /* 5 */ }, @@ -2010,17 +2015,17 @@ static const struct evlist_test test__events[] =3D { /* 6 */ }, { - .name =3D "{cycles,cache-misses,branch-misses}:e", + .name =3D "{cpu-cycles,cache-misses,branch-misses}:e", .check =3D test__exclusive_group, /* 7 */ }, { - .name =3D "cycles/name=3Dname/", + .name =3D "cpu-cycles/name=3Dname/", .check =3D test__term_equal_term, /* 8 */ }, { - .name =3D "cycles/name=3Dl1d/", + .name =3D "cpu-cycles/name=3Dl1d/", .check =3D test__term_equal_legacy, /* 9 */ }, @@ -2121,7 +2126,7 @@ static const struct evlist_test test__events_pmu[] = =3D { /* 2 */ }, { - .name =3D "cpu/name=3D'COMPLEX_CYCLES_NAME:orig=3Dcycles,desc=3Dchip-cl= ock-ticks',period=3D0x1,event=3D0x2/ukp", + .name =3D "cpu/name=3D'COMPLEX_CYCLES_NAME:orig=3Dcpu-cycles,desc=3Dchi= p-clock-ticks',period=3D0x1,event=3D0x2/ukp", .valid =3D test__pmu_cpu_event_valid, .check =3D test__checkevent_complex_name, /* 3 */ --=20 2.51.0.534.gc79095c0ca-goog