From nobody Mon Feb 9 05:52:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF450EB64DD for ; Tue, 11 Jul 2023 05:59:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231190AbjGKF7b (ORCPT ); Tue, 11 Jul 2023 01:59:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230439AbjGKF7Z (ORCPT ); Tue, 11 Jul 2023 01:59:25 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69C23E64 for ; Mon, 10 Jul 2023 22:59:20 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-57325434999so63683927b3.1 for ; Mon, 10 Jul 2023 22:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689055159; x=1691647159; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=pCvcip3cNS9Uck7qRANxqTRMPqOA6kzu5yAG3bPx7q8=; b=kgGfCtGt6f/VllzJStsFabPTDGU2UGd7nA4n71pjFUbrOxW1q26EhZnnPIVbKPK2G2 oURkOkoNRUJocZ0NDLQBhPW1Y1bT34IzxH75QLtgPu/0vrzeHfWp7ZSeF+zHrCQ6Ts5Y bInSKahA5vx9v48KISRfLD+qdLuFlKTA02Ikcmm1S7D6ee1Hx+/IVIKfiKn5rWCZ+t/n vnb8Yma6UYMKvcVAxdZGBWyzevBFz2NGj+j88BRipaykA/sZEWk1xvW1Qyt6Cy84iTSO vOAq7c9xk9qn2/M+cTILPEIcLghk4oS0tFdZGjE0dT2d+RYib/4VwcIW61pd564PxKZc IEHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689055159; x=1691647159; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pCvcip3cNS9Uck7qRANxqTRMPqOA6kzu5yAG3bPx7q8=; b=IuFkIsw1AuLFzUNUDub93NMrLxJkrk+Rf+VVrVQYkdQ5MeOFLevyS7mFUlMZfcy1Bl ZPVgaL1MNv3cRqpzK6cJ+fpvjRGjaVfBRcx339auJ8Ky7rlouWolHxptxs83gXo8MGP9 XxR302F8Rkr8xnvpAU1jA8hWuDuaeeLfqgjXGftoIxLa2VPrQ4BvR9dR3EQGtA9efStY WRbwy+BaI9rgYmSOQ/DbzEoOf04QJhnhleXzxrHSLsHjcNTEF7l4JGbgv5kQWcpHO8b3 5DfJp1dJrtopgkFBXsG+ooBiEkG8v6bfxoO9U/9t3dFtXIi/GWOI9jesKvYohiMzrmi/ mRNA== X-Gm-Message-State: ABy/qLZrHujZZdLspFpClGMco3Rmotuud7RkLYWcJjS40lkaRxAWM8TO CYiB/YmeEx/8XnBYHKAfuMIn8VOUqXxJ X-Google-Smtp-Source: APBJJlF/hQwvZLvooEgTBAGj8HUCE7NLrFqxQRoLCBxX/VAawfd2grekYqVfsjiVzIubUZjSq3dVhrixaEkk X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2efd:fc0f:9eaa:3bd5]) (user=irogers job=sendgmr) by 2002:a25:8882:0:b0:c4d:4b23:337 with SMTP id d2-20020a258882000000b00c4d4b230337mr86042ybl.11.1689055159701; Mon, 10 Jul 2023 22:59:19 -0700 (PDT) Date: Mon, 10 Jul 2023 22:58:57 -0700 In-Reply-To: <20230711055859.1242497-1-irogers@google.com> Message-Id: <20230711055859.1242497-2-irogers@google.com> Mime-Version: 1.0 References: <20230711055859.1242497-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.390.g38632f3daf-goog Subject: [PATCH v1 1/3] perf pmus: Sort pmus by name then suffix From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , Ravi Bangoria , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Sort PMUs by name. If two PMUs have the same name but differ by suffix, sort the suffixes numerically. For example, "breakpoint" comes before "cpu", "uncore_imc_free_running_0" comes before "uncore_imc_free_running_1". Signed-off-by: Ian Rogers --- tools/perf/util/pmus.c | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c index c58ba9fb6a36..3581710667b0 100644 --- a/tools/perf/util/pmus.c +++ b/tools/perf/util/pmus.c @@ -1,8 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include +#include #include #include #include @@ -33,6 +35,31 @@ static LIST_HEAD(other_pmus); static bool read_sysfs_core_pmus; static bool read_sysfs_all_pmus; =20 +static int pmu_name_len_no_suffix(const char *str, unsigned long *num) +{ + int orig_len, len; + + orig_len =3D len =3D strlen(str); + + /* Non-uncore PMUs have their full length, for example, i915. */ + if (strncmp(str, "uncore_", 7)) + return len; + + /* + * Count trailing digits and '_', if '_{num}' suffix isn't present use + * the full length. + */ + while (len > 0 && isdigit(str[len - 1])) + len--; + + if (len > 0 && len !=3D orig_len && str[len - 1] =3D=3D '_') { + if (num) + *num =3D strtoul(&str[len], NULL, 10); + return len - 1; + } + return orig_len; +} + void perf_pmus__destroy(void) { struct perf_pmu *pmu, *tmp; @@ -122,6 +149,25 @@ static struct perf_pmu *perf_pmu__find2(int dirfd, con= st char *name) return perf_pmu__lookup(core_pmu ? &core_pmus : &other_pmus, dirfd, name); } =20 +static int pmus_cmp(void *priv __maybe_unused, + const struct list_head *lhs, const struct list_head *rhs) +{ + unsigned long lhs_num, rhs_num; + struct perf_pmu *lhs_pmu =3D container_of(lhs, struct perf_pmu, list); + struct perf_pmu *rhs_pmu =3D container_of(rhs, struct perf_pmu, list); + const char *lhs_pmu_name =3D lhs_pmu->name ?: ""; + const char *rhs_pmu_name =3D rhs_pmu->name ?: ""; + int lhs_pmu_name_len =3D pmu_name_len_no_suffix(lhs_pmu_name, &lhs_num); + int rhs_pmu_name_len =3D pmu_name_len_no_suffix(rhs_pmu_name, &rhs_num); + int ret =3D strncmp(lhs_pmu_name, rhs_pmu_name, + lhs_pmu_name_len < rhs_pmu_name_len ? lhs_pmu_name_len : rhs_pmu_name_l= en); + + if (lhs_pmu_name_len !=3D rhs_pmu_name_len || ret !=3D 0 || lhs_pmu_name_= len =3D=3D 0) + return ret; + + return lhs_num < rhs_num ? -1 : (lhs_num > rhs_num ? 1 : 0); +} + /* Add all pmus in sysfs to pmu list: */ static void pmu_read_sysfs(bool core_only) { @@ -156,6 +202,8 @@ static void pmu_read_sysfs(bool core_only) if (!perf_pmu__create_placeholder_core_pmu(&core_pmus)) pr_err("Failure to set up any core PMUs\n"); } + list_sort(NULL, &core_pmus, pmus_cmp); + list_sort(NULL, &other_pmus, pmus_cmp); if (!list_empty(&core_pmus)) { read_sysfs_core_pmus =3D true; if (!core_only) --=20 2.41.0.390.g38632f3daf-goog From nobody Mon Feb 9 05:52:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C44CEB64DD for ; Tue, 11 Jul 2023 05:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230474AbjGKF7d (ORCPT ); Tue, 11 Jul 2023 01:59:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbjGKF70 (ORCPT ); Tue, 11 Jul 2023 01:59:26 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F04101AC for ; Mon, 10 Jul 2023 22:59:22 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-57704aace46so57157127b3.2 for ; Mon, 10 Jul 2023 22:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689055162; x=1691647162; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=aeSO6Ab0Eyw2ukZaayVI7Jjvjc4sNwkQ48k5lNueGS0=; b=gjXOdgljao5xPM58mg4voHt4zoSAKDxixNMnOBYiCtKDpPGbNg4IIwH76dxS0S2r7D 44z51bcKPkY5eFU3d87bjW2/w5Kn/9Uy5mALMzCewror48jlSfTu2lgtXEU3KncIey7x FFm6VaizZ7DsoOvhmUY6Slv2uH53++P5Kkg/ddNLwDD58JvQ6b+TXKRlcjbDAdZWWvMc yvh3fpIbD28HH5qwyJjdQ/FsFIiu90RCGYy9Q5vxhqkquGTRyM4MXsQY8JOBNg/ReKIW JpfQPubeGBQPPv8kUskm2kncwX60Kidh0bIDO4q3+ep6u0N05EIpq6d70PoRe8QdvGG0 R/jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689055162; x=1691647162; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aeSO6Ab0Eyw2ukZaayVI7Jjvjc4sNwkQ48k5lNueGS0=; b=Q2tBxk3BPldRyfv/x/9N6ey8eDMMFeND7KQW7ttvqtxuhbI/Z1gX8hKq/jnKjvm9V6 bWsBnMVHyksOpYB47IdDu+mbm7iUT9sH2pZfTC8PXUyei9I6MKsqMQ5o3t31fdO5uHQm YK4JXTcwHx1ID87k0C2D+Vr3wFUevaS2US0A712zk1QtP+cM3JSZzXv+IaoqMjwbMB0b wFO7JQVNnkpCBFf9k/D5dVrPlsy9ZmbfrT6D5xulwBHlyj+xx8IPAqFGzEF+YUpbfstr n8mb1ODVHHwyMqrheQdHgArugeIRmhFxqcNy4SYizg2Ajr0YY5kuQvhCYHprVlfc6naR 9atg== X-Gm-Message-State: ABy/qLbYCKLYxG05b74LVSJtcnmV5HZJFhVISh/WQQbR3/3dwhRYMn7a ZcXpSCReRD0oj+EvZ07wKtlbwQgHUs+/ X-Google-Smtp-Source: APBJJlGQJZh+yd9CTr3OHMJ/77Fhyx9lb5YbPdo/rb/ivgX6ul3fPMNM2KB6+aemsZegJ3B80xOOqwmEx+le X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2efd:fc0f:9eaa:3bd5]) (user=irogers job=sendgmr) by 2002:a81:ac47:0:b0:576:92da:cd3d with SMTP id z7-20020a81ac47000000b0057692dacd3dmr107380ywj.8.1689055162240; Mon, 10 Jul 2023 22:59:22 -0700 (PDT) Date: Mon, 10 Jul 2023 22:58:58 -0700 In-Reply-To: <20230711055859.1242497-1-irogers@google.com> Message-Id: <20230711055859.1242497-3-irogers@google.com> Mime-Version: 1.0 References: <20230711055859.1242497-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.390.g38632f3daf-goog Subject: [PATCH v1 2/3] perf pmus: Add scan that ignores duplicates, use for perf list From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , Ravi Bangoria , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When there are multiple PMUs that differ only by suffix, just list the first one and skip all others. As the PMUs are sorted, the scan routine checks that the PMU names match and the numbers are consecutive. Signed-off-by: Ian Rogers --- tools/perf/util/pmus.c | 48 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c index 3581710667b0..87e5fb74e121 100644 --- a/tools/perf/util/pmus.c +++ b/tools/perf/util/pmus.c @@ -275,6 +275,50 @@ struct perf_pmu *perf_pmus__scan_core(struct perf_pmu = *pmu) return NULL; } =20 +static struct perf_pmu *perf_pmus__scan_skip_duplicates(struct perf_pmu *p= mu) +{ + bool use_core_pmus =3D !pmu || pmu->is_core; + int last_pmu_name_len =3D 0; + unsigned long last_pmu_num =3D 0; + const char *last_pmu_name =3D (pmu && pmu->name) ? pmu->name : ""; + + if (!pmu) { + pmu_read_sysfs(/*core_only=3D*/false); + pmu =3D list_prepare_entry(pmu, &core_pmus, list); + } else + last_pmu_name_len =3D pmu_name_len_no_suffix(pmu->name ?: "", &last_pmu_= num); + + if (use_core_pmus) { + list_for_each_entry_continue(pmu, &core_pmus, list) { + unsigned long pmu_num =3D 0; + int pmu_name_len =3D pmu_name_len_no_suffix(pmu->name ?: "", &pmu_num); + + if (last_pmu_name_len =3D=3D pmu_name_len && + (last_pmu_num + 1 =3D=3D pmu_num) && + !strncmp(last_pmu_name, pmu->name ?: "", pmu_name_len)) { + last_pmu_num++; + continue; + } + return pmu; + } + pmu =3D NULL; + pmu =3D list_prepare_entry(pmu, &other_pmus, list); + } + list_for_each_entry_continue(pmu, &other_pmus, list) { + unsigned long pmu_num =3D 0; + int pmu_name_len =3D pmu_name_len_no_suffix(pmu->name ?: "", &pmu_num); + + if (last_pmu_name_len =3D=3D pmu_name_len && + (last_pmu_num + 1 =3D=3D pmu_num) && + !strncmp(last_pmu_name, pmu->name ?: "", pmu_name_len)) { + last_pmu_num++; + continue; + } + return pmu; + } + return NULL; +} + const struct perf_pmu *perf_pmus__pmu_for_pmu_filter(const char *str) { struct perf_pmu *pmu =3D NULL; @@ -432,7 +476,7 @@ void perf_pmus__print_pmu_events(const struct print_cal= lbacks *print_cb, void *p =20 pmu =3D NULL; len =3D 0; - while ((pmu =3D perf_pmus__scan(pmu)) !=3D NULL) { + while ((pmu =3D perf_pmus__scan_skip_duplicates(pmu)) !=3D NULL) { list_for_each_entry(event, &pmu->aliases, list) len++; if (pmu->selectable) @@ -445,7 +489,7 @@ void perf_pmus__print_pmu_events(const struct print_cal= lbacks *print_cb, void *p } pmu =3D NULL; j =3D 0; - while ((pmu =3D perf_pmus__scan(pmu)) !=3D NULL) { + while ((pmu =3D perf_pmus__scan_skip_duplicates(pmu)) !=3D NULL) { bool is_cpu =3D pmu->is_core; =20 list_for_each_entry(event, &pmu->aliases, list) { --=20 2.41.0.390.g38632f3daf-goog From nobody Mon Feb 9 05:52:13 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87CD0EB64DC for ; Tue, 11 Jul 2023 05:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231256AbjGKF7i (ORCPT ); Tue, 11 Jul 2023 01:59:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbjGKF73 (ORCPT ); Tue, 11 Jul 2023 01:59:29 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A354EE49 for ; Mon, 10 Jul 2023 22:59:25 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-570553a18deso63547077b3.2 for ; Mon, 10 Jul 2023 22:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689055165; x=1691647165; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=vHH47SfpScUGFxKQhJm1mmTUrzJDod/Xuvw5vyIRsxc=; b=LpOBs94ljdTymoJcs1ClmQDribais2EEw9Mpx8cWUs53b5omHGBZyOnhd+PmexP81P MTR8rdrVo3R0tXs7mey0rTyT5+ey3M6Ve0BrJNJGP0a6GbKPeMkLUPhcLR42qoWzjA8s jZK76di5xMnvrFuEwlKsChLtWCJiIBlyHh6lo789oztEywH7fjfTI17qyulKXqoyJ+Hp O99ZDXhJP0p/1rRSm7rWeRT5b6c6Zs3iPzmoa9hln2yemsXeIdmdwTpWtFQ8J/iIk5Jz TqfsxWZeoyD7x3owN+Hc2o+VTQu1Y7JqJSPu7gbcTkWrpDCfcHsegVBd60ufNp2nI4SC 0cEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689055165; x=1691647165; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vHH47SfpScUGFxKQhJm1mmTUrzJDod/Xuvw5vyIRsxc=; b=YD8utBe9Z7ljtcuxh/HMG4t10PP5nXkAXo3RsV84AX9dVmotX/IXXtLIbKqRp4FV4g 9p/0fayN43fVGJWJrvTIDhx7KjgeJc42zANSDLQPUbjCffkwvJrDT5Yw1rYPPg9T5Ex8 6MspXhMT7JMVreL2LuvN3NoZee2+XIsCw2qUW3FrimZxFYclQw7dNmZh5flt0Okf1SeV TYmZoqmVLuf+h9b29WgwH/ayKzkzLDEY8NHKBAEFd7PRaprbbeTL3icBDFLZhYA2ZN0z HHeLzo0PiPOnsY+MWFlpzRlKoKeQaThv3mf4rG1bJ/dMJ6pUDpZ/fRP6ZD1osfQAqRaR JYag== X-Gm-Message-State: ABy/qLavKYTje1Hkoksl0bMA0NJJxk6+hfjum4ssppGRkeuMesgMfrBW Ecn0vZn2aJsIIlTMPJ4eTrutJ53L/Dpg X-Google-Smtp-Source: APBJJlEWwPStaCrLA06Y628txzlo5JavMlFYwkiXOj/gztJc11CCwAbnT9FqlwSBkfNm4U927gRchxVv6xIS X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:2efd:fc0f:9eaa:3bd5]) (user=irogers job=sendgmr) by 2002:a81:e30d:0:b0:576:a5a8:f686 with SMTP id q13-20020a81e30d000000b00576a5a8f686mr112446ywl.9.1689055164831; Mon, 10 Jul 2023 22:59:24 -0700 (PDT) Date: Mon, 10 Jul 2023 22:58:59 -0700 In-Reply-To: <20230711055859.1242497-1-irogers@google.com> Message-Id: <20230711055859.1242497-4-irogers@google.com> Mime-Version: 1.0 References: <20230711055859.1242497-1-irogers@google.com> X-Mailer: git-send-email 2.41.0.390.g38632f3daf-goog Subject: [PATCH v1 3/3] perf pmus: Don't print PMU suffix in list From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Kan Liang , Ravi Bangoria , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Duplicate PMUs are no longer printed but the suffix of the first is printed. Avoid printing the suffix as multiple PMUs are matched. Before: ``` $ perf list ... uncore_imc_free_running_0/data_read/ [Kernel PMU event] uncore_imc_free_running_0/data_total/ [Kernel PMU event] uncore_imc_free_running_0/data_write/ [Kernel PMU event] ``` After: ``` $ perf list ... uncore_imc_free_running/data_read/ [Kernel PMU event] uncore_imc_free_running/data_total/ [Kernel PMU event] uncore_imc_free_running/data_write/ [Kernel PMU event] ``` Signed-off-by: Ian Rogers --- tools/perf/util/pmus.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c index 87e5fb74e121..c25b9cb70050 100644 --- a/tools/perf/util/pmus.c +++ b/tools/perf/util/pmus.c @@ -443,7 +443,8 @@ static char *format_alias(char *buf, int len, const str= uct perf_pmu *pmu, const struct perf_pmu_alias *alias) { struct parse_events_term *term; - int used =3D snprintf(buf, len, "%s/%s", pmu->name, alias->name); + int pmu_name_len =3D pmu_name_len_no_suffix(pmu->name, /*num=3D*/NULL); + int used =3D snprintf(buf, len, "%.*s/%s", pmu_name_len, pmu->name, alias= ->name); =20 list_for_each_entry(term, &alias->terms, list) { if (term->type_val =3D=3D PARSE_EVENTS__TERM_TYPE_STR) @@ -512,6 +513,7 @@ void perf_pmus__print_pmu_events(const struct print_cal= lbacks *print_cb, void *p *desc =3D NULL, *long_desc =3D NULL, *encoding_desc =3D NULL, *topic =3D NULL, *pmu_name =3D NULL; + int pmu_name_len; bool deprecated =3D false; size_t buf_used; =20 @@ -522,7 +524,8 @@ void perf_pmus__print_pmu_events(const struct print_cal= lbacks *print_cb, void *p if (!aliases[j].event) { /* A selectable event. */ pmu_name =3D aliases[j].pmu->name; - buf_used =3D snprintf(buf, sizeof(buf), "%s//", pmu_name) + 1; + pmu_name_len =3D pmu_name_len_no_suffix(pmu_name, /*num=3D*/NULL); + buf_used =3D snprintf(buf, sizeof(buf), "%.*s//", pmu_name_len, pmu_nam= e) + 1; name =3D buf; } else { if (aliases[j].event->desc) { @@ -548,8 +551,10 @@ void perf_pmus__print_pmu_events(const struct print_ca= llbacks *print_cb, void *p long_desc =3D aliases[j].event->long_desc; topic =3D aliases[j].event->topic; encoding_desc =3D buf + buf_used; + pmu_name_len =3D pmu_name_len_no_suffix(pmu_name, /*num=3D*/NULL); buf_used +=3D snprintf(buf + buf_used, sizeof(buf) - buf_used, - "%s/%s/", pmu_name, aliases[j].event->str) + 1; + "%.*s/%s/", pmu_name_len, pmu_name, + aliases[j].event->str) + 1; deprecated =3D aliases[j].event->deprecated; } print_cb->print_event(print_state, --=20 2.41.0.390.g38632f3daf-goog