From nobody Sat Apr 11 11:09:12 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 0F416C00140 for ; Fri, 12 Aug 2022 23:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238491AbiHLXLS (ORCPT ); Fri, 12 Aug 2022 19:11:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238097AbiHLXK3 (ORCPT ); Fri, 12 Aug 2022 19:10:29 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E3239D117 for ; Fri, 12 Aug 2022 16:10:24 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id j11-20020a05690212cb00b006454988d225so1828556ybu.10 for ; Fri, 12 Aug 2022 16:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc; bh=zprLe3z6GS8nmW2T+04nxrIBRrafJR/G9iUpcioBWxI=; b=dcZEL3cR1Azc7uP1/qAFxYhtku9U3I9OhhFGefft2NxD/BvtOD103q0GDjD+OdVDgj hZ0U0ZfmEbmjmB6iL6gmGIwYTABoSn7sUfUWLVaQ3Jn+NlIr9spbGiyqiHYnf9sO0RSp g4cn2carsPAlgE1615xTsq8qeq8mFDOlobxylV9rhTCieBbsZqL5WJykzFvS0HYokT+8 +y8ltmfO2lxEufCbtMaVhzdWjsO0fkeryU2YhJWKLa944Xc7azCjq+fykab02i5Xp/7Q t9/rKHQaURmjwQj8rjtUwCp4r2MfEGy4JOpumK+v/B9iPH2+bqeVG5F3sU01zCMpkFUQ aYIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=zprLe3z6GS8nmW2T+04nxrIBRrafJR/G9iUpcioBWxI=; b=Yld7/DsxiOsC8w9h9IjrSiTyimvkiUSWoM0HBwoh7k+82QJdJ0lqZPFlkl7CiQmbHE 5D9kHTqZBx99drKz+V3/ph8G1h9fprn+6c5bxdy/x//xx5BcD2nh8oRZkRFi7blf0JKa qWto0IIyHsTDp541x4+2lVRlYgYV61JU42w92i9E43UwJuKlr+hfqDRPf+l6P3bTsYUi nd2ym0cERnBw2U9DmJj491Ezt/mYexRpAquyyaQfIXvb3cyXAVAO3dxca+WaWKteq/Mh gHsx/yqy+IKGXXk8W+sm3MnaNlzhuuAbzo54Zq0u84ipkOhVSPnLQkb+JPDKZvijp7eh lNCw== X-Gm-Message-State: ACgBeo1tL1bmK2pWf9OANYcM/U+3+maTb/qu5+DnuXxM+1HlIxrBNDwU HFvCrEPKEPce6lS1zjId6Fs8+4wr+aR0 X-Google-Smtp-Source: AA6agR5oPW2xGQeIidUC15wyzZ/XWPatNKTsSkkTJML7GOSytjJ3utI07u2Ae+Til81DVLjpiKaWIWw+tZKA X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:d668:2937:8218:c5ec]) (user=irogers job=sendgmr) by 2002:a25:9306:0:b0:683:75e4:e03f with SMTP id f6-20020a259306000000b0068375e4e03fmr3237759ybo.172.1660345824061; Fri, 12 Aug 2022 16:10:24 -0700 (PDT) Date: Fri, 12 Aug 2022 16:09:46 -0700 In-Reply-To: <20220812230949.683239-1-irogers@google.com> Message-Id: <20220812230949.683239-12-irogers@google.com> Mime-Version: 1.0 References: <20220812230949.683239-1-irogers@google.com> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH v5 11/14] perf pmu-events: Hide the pmu_events From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andi Kleen , Zhengjun Xing , Ravi Bangoria , Kan Liang , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org Cc: Stephane Eranian , Ian Rogers Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Hide that the pmu_event structs are an array with a new wrapper struct. Signed-off-by: Ian Rogers --- tools/perf/arch/arm64/util/pmu.c | 2 +- tools/perf/pmu-events/empty-pmu-events.c | 44 ++++++++++++---------- tools/perf/pmu-events/jevents.py | 47 +++++++++++++----------- tools/perf/pmu-events/pmu-events.h | 12 +++--- tools/perf/tests/expand-cgroup.c | 2 +- tools/perf/tests/parse-metric.c | 2 +- tools/perf/tests/pmu-events.c | 16 ++++---- tools/perf/util/metricgroup.c | 42 ++++++++++----------- tools/perf/util/metricgroup.h | 5 +-- tools/perf/util/pmu.c | 10 ++--- tools/perf/util/pmu.h | 4 +- tools/perf/util/s390-sample-raw.c | 6 +-- 12 files changed, 101 insertions(+), 91 deletions(-) diff --git a/tools/perf/arch/arm64/util/pmu.c b/tools/perf/arch/arm64/util/= pmu.c index 92d774647f6e..f849b1e88d43 100644 --- a/tools/perf/arch/arm64/util/pmu.c +++ b/tools/perf/arch/arm64/util/pmu.c @@ -3,7 +3,7 @@ #include "../../../util/cpumap.h" #include "../../../util/pmu.h" =20 -const struct pmu_event *pmu_events_table__find(void) +const struct pmu_events_table *pmu_events_table__find(void) { struct perf_pmu *pmu =3D NULL; =20 diff --git a/tools/perf/pmu-events/empty-pmu-events.c b/tools/perf/pmu-even= ts/empty-pmu-events.c index bee1967baa2b..5ed8c0aa4817 100644 --- a/tools/perf/pmu-events/empty-pmu-events.c +++ b/tools/perf/pmu-events/empty-pmu-events.c @@ -176,6 +176,10 @@ static const struct pmu_event pme_test_soc_cpu[] =3D { }, }; =20 +/* Struct used to make the PMU event table implementation opaque to caller= s. */ +struct pmu_events_table { + const struct pmu_event *entries; +}; =20 /* * Map a CPU to its table of PMU events. The CPU is identified by the @@ -188,7 +192,7 @@ static const struct pmu_event pme_test_soc_cpu[] =3D { struct pmu_events_map { const char *arch; const char *cpuid; - const struct pmu_event *table; + const struct pmu_events_table table; }; =20 /* @@ -199,12 +203,12 @@ static const struct pmu_events_map pmu_events_map[] = =3D { { .arch =3D "testarch", .cpuid =3D "testcpu", - .table =3D pme_test_soc_cpu, + .table =3D { pme_test_soc_cpu }, }, { .arch =3D 0, .cpuid =3D 0, - .table =3D 0, + .table =3D { 0 }, }, }; =20 @@ -234,23 +238,23 @@ static const struct pmu_event pme_test_soc_sys[] =3D { =20 struct pmu_sys_events { const char *name; - const struct pmu_event *table; + const struct pmu_events_table table; }; =20 static const struct pmu_sys_events pmu_sys_event_tables[] =3D { { - .table =3D pme_test_soc_sys, + .table =3D { pme_test_soc_sys }, .name =3D "pme_test_soc_sys", }, { - .table =3D 0 + .table =3D { 0 } }, }; =20 -int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_eve= nt_iter_fn fn, +int pmu_events_table_for_each_event(const struct pmu_events_table *table, = pmu_event_iter_fn fn, void *data) { - for (const struct pmu_event *pe =3D &table[0]; + for (const struct pmu_event *pe =3D &table->entries[0]; pe->name || pe->metric_group || pe->metric_name; pe++) { int ret =3D fn(pe, table, data); @@ -261,9 +265,9 @@ int pmu_events_table_for_each_event(const struct pmu_ev= ent *table, pmu_event_ite return 0; } =20 -const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu) +const struct pmu_events_table *perf_pmu__find_table(struct perf_pmu *pmu) { - const struct pmu_event *table =3D NULL; + const struct pmu_events_table *table =3D NULL; char *cpuid =3D perf_pmu__getcpuid(pmu); int i; =20 @@ -277,11 +281,11 @@ const struct pmu_event *perf_pmu__find_table(struct p= erf_pmu *pmu) for (;;) { const struct pmu_events_map *map =3D &pmu_events_map[i++]; =20 - if (!map->table) + if (!map->cpuid) break; =20 if (!strcmp_cpuid_str(map->cpuid, cpuid)) { - table =3D map->table; + table =3D &map->table; break; } } @@ -289,13 +293,13 @@ const struct pmu_event *perf_pmu__find_table(struct p= erf_pmu *pmu) return table; } =20 -const struct pmu_event *find_core_events_table(const char *arch, const cha= r *cpuid) +const struct pmu_events_table *find_core_events_table(const char *arch, co= nst char *cpuid) { for (const struct pmu_events_map *tables =3D &pmu_events_map[0]; - tables->table; + tables->arch; tables++) { if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(tables->cpuid, cpui= d)) - return tables->table; + return &tables->table; } return NULL; } @@ -303,9 +307,9 @@ const struct pmu_event *find_core_events_table(const ch= ar *arch, const char *cpu int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data) { for (const struct pmu_events_map *tables =3D &pmu_events_map[0]; - tables->table; + tables->arch; tables++) { - int ret =3D pmu_events_table_for_each_event(tables->table, fn, data); + int ret =3D pmu_events_table_for_each_event(&tables->table, fn, data); =20 if (ret) return ret; @@ -313,13 +317,13 @@ int pmu_for_each_core_event(pmu_event_iter_fn fn, voi= d *data) return 0; } =20 -const struct pmu_event *find_sys_events_table(const char *name) +const struct pmu_events_table *find_sys_events_table(const char *name) { for (const struct pmu_sys_events *tables =3D &pmu_sys_event_tables[0]; tables->name; tables++) { if (!strcmp(tables->name, name)) - return tables->table; + return &tables->table; } return NULL; } @@ -329,7 +333,7 @@ int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *= data) for (const struct pmu_sys_events *tables =3D &pmu_sys_event_tables[0]; tables->name; tables++) { - int ret =3D pmu_events_table_for_each_event(tables->table, fn, data); + int ret =3D pmu_events_table_for_each_event(&tables->table, fn, data); =20 if (ret) return ret; diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jeven= ts.py index 977f2061a990..4b7948ba57d6 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -335,6 +335,11 @@ def process_one_file(parents: Sequence[str], item: os.= DirEntry) -> None: def print_mapping_table(archs: Sequence[str]) -> None: """Read the mapfile and generate the struct from cpuid string to event t= able.""" _args.output_file.write(""" +/* Struct used to make the PMU event table implementation opaque to caller= s. */ +struct pmu_events_table { + const struct pmu_event *entries; +}; + /* * Map a CPU to its table of PMU events. The CPU is identified by the * cpuid field, which is an arch-specific identifier for the CPU. @@ -346,7 +351,7 @@ def print_mapping_table(archs: Sequence[str]) -> None: struct pmu_events_map { const char *arch; const char *cpuid; - const struct pmu_event *table; + struct pmu_events_table table; }; =20 /* @@ -360,7 +365,7 @@ const struct pmu_events_map pmu_events_map[] =3D { _args.output_file.write("""{ \t.arch =3D "testarch", \t.cpuid =3D "testcpu", -\t.table =3D pme_test_soc_cpu, +\t.table =3D { pme_test_soc_cpu }, }, """) else: @@ -375,7 +380,7 @@ const struct pmu_events_map pmu_events_map[] =3D { _args.output_file.write(f"""{{ \t.arch =3D "{arch}", \t.cpuid =3D "{cpuid}", -\t.table =3D {tblname} +\t.table =3D {{ {tblname} }} }}, """) first =3D False @@ -383,7 +388,7 @@ const struct pmu_events_map pmu_events_map[] =3D { _args.output_file.write("""{ \t.arch =3D 0, \t.cpuid =3D 0, -\t.table =3D 0, +\t.table =3D { 0 }, } }; """) @@ -394,26 +399,26 @@ def print_system_mapping_table() -> None: _args.output_file.write(""" struct pmu_sys_events { \tconst char *name; -\tconst struct pmu_event *table; +\tstruct pmu_events_table table; }; =20 static const struct pmu_sys_events pmu_sys_event_tables[] =3D { """) for tblname in _sys_event_tables: _args.output_file.write(f"""\t{{ -\t\t.table =3D {tblname}, +\t\t.table =3D {{ {tblname} }}, \t\t.name =3D \"{tblname}\", \t}}, """) _args.output_file.write("""\t{ -\t\t.table =3D 0 +\t\t.table =3D { 0 } \t}, }; =20 -int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_eve= nt_iter_fn fn, +int pmu_events_table_for_each_event(const struct pmu_events_table *table, = pmu_event_iter_fn fn, void *data) { - for (const struct pmu_event *pe =3D &table[0]; + for (const struct pmu_event *pe =3D &table->entries[0]; pe->name || pe->metric_group || pe->metric_name; pe++) { int ret =3D fn(pe, table, data); @@ -424,9 +429,9 @@ int pmu_events_table_for_each_event(const struct pmu_ev= ent *table, pmu_event_ite return 0; } =20 -const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu) +const struct pmu_events_table *perf_pmu__find_table(struct perf_pmu *pmu) { - const struct pmu_event *table =3D NULL; + const struct pmu_events_table *table =3D NULL; char *cpuid =3D perf_pmu__getcpuid(pmu); int i; =20 @@ -439,11 +444,11 @@ const struct pmu_event *perf_pmu__find_table(struct p= erf_pmu *pmu) i =3D 0; for (;;) { const struct pmu_events_map *map =3D &pmu_events_map[i++]; - if (!map->table) + if (!map->arch) break; =20 if (!strcmp_cpuid_str(map->cpuid, cpuid)) { - table =3D map->table; + table =3D &map->table; break; } } @@ -451,13 +456,13 @@ const struct pmu_event *perf_pmu__find_table(struct p= erf_pmu *pmu) return table; } =20 -const struct pmu_event *find_core_events_table(const char *arch, const cha= r *cpuid) +const struct pmu_events_table *find_core_events_table(const char *arch, co= nst char *cpuid) { for (const struct pmu_events_map *tables =3D &pmu_events_map[0]; - tables->table; + tables->arch; tables++) { if (!strcmp(tables->arch, arch) && !strcmp_cpuid_str(table= s->cpuid, cpuid)) - return tables->table; + return &tables->table; } return NULL; } @@ -465,9 +470,9 @@ const struct pmu_event *find_core_events_table(const ch= ar *arch, const char *cpu int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data) { for (const struct pmu_events_map *tables =3D &pmu_events_map[0]; - tables->table; + tables->arch; tables++) { - int ret =3D pmu_events_table_for_each_event(tables->table,= fn, data); + int ret =3D pmu_events_table_for_each_event(&tables->table= , fn, data); =20 if (ret) return ret; @@ -475,13 +480,13 @@ int pmu_for_each_core_event(pmu_event_iter_fn fn, voi= d *data) return 0; } =20 -const struct pmu_event *find_sys_events_table(const char *name) +const struct pmu_events_table *find_sys_events_table(const char *name) { for (const struct pmu_sys_events *tables =3D &pmu_sys_event_tables= [0]; tables->name; tables++) { if (!strcmp(tables->name, name)) - return tables->table; + return &tables->table; } return NULL; } @@ -491,7 +496,7 @@ int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *= data) for (const struct pmu_sys_events *tables =3D &pmu_sys_event_tables= [0]; tables->name; tables++) { - int ret =3D pmu_events_table_for_each_event(tables->table,= fn, data); + int ret =3D pmu_events_table_for_each_event(&tables->table= , fn, data); =20 if (ret) return ret; diff --git a/tools/perf/pmu-events/pmu-events.h b/tools/perf/pmu-events/pmu= -events.h index 70672842f77f..fe343c4d8016 100644 --- a/tools/perf/pmu-events/pmu-events.h +++ b/tools/perf/pmu-events/pmu-events.h @@ -30,18 +30,20 @@ struct pmu_event { const char *metric_constraint; }; =20 +struct pmu_events_table; + typedef int (*pmu_event_iter_fn)(const struct pmu_event *pe, - const struct pmu_event *table, + const struct pmu_events_table *table, void *data); =20 -int pmu_events_table_for_each_event(const struct pmu_event *table, pmu_eve= nt_iter_fn fn, +int pmu_events_table_for_each_event(const struct pmu_events_table *table, = pmu_event_iter_fn fn, void *data); =20 -const struct pmu_event *perf_pmu__find_table(struct perf_pmu *pmu); -const struct pmu_event *find_core_events_table(const char *arch, const cha= r *cpuid); +const struct pmu_events_table *perf_pmu__find_table(struct perf_pmu *pmu); +const struct pmu_events_table *find_core_events_table(const char *arch, co= nst char *cpuid); int pmu_for_each_core_event(pmu_event_iter_fn fn, void *data); =20 -const struct pmu_event *find_sys_events_table(const char *name); +const struct pmu_events_table *find_sys_events_table(const char *name); int pmu_for_each_sys_event(pmu_event_iter_fn fn, void *data); =20 #endif diff --git a/tools/perf/tests/expand-cgroup.c b/tools/perf/tests/expand-cgr= oup.c index e79ee8621a90..51fb5f34c1dd 100644 --- a/tools/perf/tests/expand-cgroup.c +++ b/tools/perf/tests/expand-cgroup.c @@ -180,7 +180,7 @@ static int expand_metric_events(void) struct evlist *evlist; struct rblist metric_events; const char metric_str[] =3D "CPI"; - const struct pmu_event *pme_test; + const struct pmu_events_table *pme_test; =20 evlist =3D evlist__new(); TEST_ASSERT_VAL("failed to get evlist", evlist); diff --git a/tools/perf/tests/parse-metric.c b/tools/perf/tests/parse-metri= c.c index 30c7091857b8..68f5a2a03242 100644 --- a/tools/perf/tests/parse-metric.c +++ b/tools/perf/tests/parse-metric.c @@ -72,7 +72,7 @@ static int __compute_metric(const char *name, struct valu= e *vals, struct rblist metric_events =3D { .nr_entries =3D 0, }; - const struct pmu_event *pme_test; + const struct pmu_events_table *pme_test; struct perf_cpu_map *cpus; struct runtime_stat st; struct evlist *evlist; diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c index e308d480f0fb..097e05c796ab 100644 --- a/tools/perf/tests/pmu-events.c +++ b/tools/perf/tests/pmu-events.c @@ -424,7 +424,7 @@ static int compare_alias_to_test_event(struct perf_pmu_= alias *alias, } =20 static int test__pmu_event_table_core_callback(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *data) { int *map_events =3D data; @@ -461,7 +461,7 @@ static int test__pmu_event_table_core_callback(const st= ruct pmu_event *pe, } =20 static int test__pmu_event_table_sys_callback(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *data) { int *map_events =3D data; @@ -495,8 +495,8 @@ static int test__pmu_event_table_sys_callback(const str= uct pmu_event *pe, static int test__pmu_event_table(struct test_suite *test __maybe_unused, int subtest __maybe_unused) { - const struct pmu_event *sys_event_table =3D find_sys_events_table("pme_te= st_soc_sys"); - const struct pmu_event *table =3D find_core_events_table("testarch", "tes= tcpu"); + const struct pmu_events_table *sys_event_table =3D find_sys_events_table(= "pme_test_soc_sys"); + const struct pmu_events_table *table =3D find_core_events_table("testarch= ", "testcpu"); int map_events =3D 0, expected_events, err; =20 /* ignore 3x sentinels */ @@ -544,7 +544,7 @@ static int __test_core_pmu_event_aliases(char *pmu_name= , int *count) struct perf_pmu *pmu; LIST_HEAD(aliases); int res =3D 0; - const struct pmu_event *table =3D find_core_events_table("testarch", "tes= tcpu"); + const struct pmu_events_table *table =3D find_core_events_table("testarch= ", "testcpu"); struct perf_pmu_alias *a, *tmp; =20 if (!table) @@ -597,7 +597,7 @@ static int __test_uncore_pmu_event_aliases(struct perf_= pmu_test_pmu *test_pmu) struct perf_pmu *pmu =3D &test_pmu->pmu; const char *pmu_name =3D pmu->name; struct perf_pmu_alias *a, *tmp, *alias; - const struct pmu_event *events_table; + const struct pmu_events_table *events_table; LIST_HEAD(aliases); int res =3D 0; =20 @@ -839,7 +839,7 @@ struct metric { struct metric_ref metric_ref; }; =20 -static int test__parsing_callback(const struct pmu_event *pe, const struct= pmu_event *table, +static int test__parsing_callback(const struct pmu_event *pe, const struct= pmu_events_table *table, void *data) { int *failures =3D data; @@ -1016,7 +1016,7 @@ static int metric_parse_fake(const char *str) } =20 static int test__parsing_fake_callback(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *data __maybe_unused) { if (!pe->metric_expr) diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c index cae97b6dc5bc..42a5c8ae915e 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -508,7 +508,7 @@ struct metricgroup_iter_data { }; =20 static int metricgroup__sys_event_iter(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table, void *data) { struct metricgroup_iter_data *d =3D data; @@ -529,7 +529,7 @@ static int metricgroup__sys_event_iter(const struct pmu= _event *pe, } =20 static int metricgroup__print_sys_event_iter(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *data) { struct metricgroup_print_sys_idata *d =3D data; @@ -549,7 +549,7 @@ struct metricgroup_print_data { }; =20 static int metricgroup__print_callback(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *vdata) { struct metricgroup_print_data *data =3D vdata; @@ -571,7 +571,7 @@ void metricgroup__print(bool metrics, bool metricgroups= , char *filter, struct rblist groups; struct rb_node *node, *next; struct strlist *metriclist =3D NULL; - const struct pmu_event *table; + const struct pmu_events_table *table; =20 if (!metricgroups) { metriclist =3D strlist__new(NULL, NULL); @@ -876,7 +876,7 @@ struct metricgroup_add_iter_data { bool metric_no_group; struct metric *root_metric; const struct visited_metric *visited; - const struct pmu_event *table; + const struct pmu_events_table *table; }; =20 static int add_metric(struct list_head *metric_list, @@ -885,7 +885,7 @@ static int add_metric(struct list_head *metric_list, bool metric_no_group, struct metric *root_metric, const struct visited_metric *visited, - const struct pmu_event *table); + const struct pmu_events_table *table); =20 /** * resolve_metric - Locate metrics within the root metric and recursively = add @@ -908,7 +908,7 @@ static int resolve_metric(struct list_head *metric_list, bool metric_no_group, struct metric *root_metric, const struct visited_metric *visited, - const struct pmu_event *table) + const struct pmu_events_table *table) { struct hashmap_entry *cur; size_t bkt; @@ -986,7 +986,7 @@ static int __add_metric(struct list_head *metric_list, int runtime, struct metric *root_metric, const struct visited_metric *visited, - const struct pmu_event *table) + const struct pmu_events_table *table) { const struct visited_metric *vm; int ret; @@ -1077,7 +1077,7 @@ struct metricgroup__find_metric_data { }; =20 static int metricgroup__find_metric_callback(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *vdata) { struct metricgroup__find_metric_data *data =3D vdata; @@ -1090,7 +1090,7 @@ static int metricgroup__find_metric_callback(const st= ruct pmu_event *pe, } =20 const struct pmu_event *metricgroup__find_metric(const char *metric, - const struct pmu_event *table) + const struct pmu_events_table *table) { struct metricgroup__find_metric_data data =3D { .metric =3D metric, @@ -1108,7 +1108,7 @@ static int add_metric(struct list_head *metric_list, bool metric_no_group, struct metric *root_metric, const struct visited_metric *visited, - const struct pmu_event *table) + const struct pmu_events_table *table) { int ret =3D 0; =20 @@ -1136,8 +1136,8 @@ static int add_metric(struct list_head *metric_list, } =20 static int metricgroup__add_metric_sys_event_iter(const struct pmu_event *= pe, - const struct pmu_event *table __maybe_unused, - void *data) + const struct pmu_events_table *table __maybe_unused, + void *data) { struct metricgroup_add_iter_data *d =3D data; int ret; @@ -1193,7 +1193,7 @@ struct metricgroup__add_metric_data { }; =20 static int metricgroup__add_metric_callback(const struct pmu_event *pe, - const struct pmu_event *table, + const struct pmu_events_table *table, void *vdata) { struct metricgroup__add_metric_data *data =3D vdata; @@ -1227,7 +1227,7 @@ static int metricgroup__add_metric_callback(const str= uct pmu_event *pe, static int metricgroup__add_metric(const char *metric_name, const char *mo= difier, bool metric_no_group, struct list_head *metric_list, - const struct pmu_event *table) + const struct pmu_events_table *table) { LIST_HEAD(list); int ret; @@ -1296,7 +1296,7 @@ static int metricgroup__add_metric(const char *metric= _name, const char *modifier */ static int metricgroup__add_metric_list(const char *list, bool metric_no_g= roup, struct list_head *metric_list, - const struct pmu_event *table) + const struct pmu_events_table *table) { char *list_itr, *list_copy, *metric_name, *modifier; int ret, count =3D 0; @@ -1504,7 +1504,7 @@ static int parse_groups(struct evlist *perf_evlist, c= onst char *str, bool metric_no_merge, struct perf_pmu *fake_pmu, struct rblist *metric_events_list, - const struct pmu_event *table) + const struct pmu_events_table *table) { struct evlist *combined_evlist =3D NULL; LIST_HEAD(metric_list); @@ -1650,14 +1650,14 @@ int metricgroup__parse_groups(const struct option *= opt, struct rblist *metric_events) { struct evlist *perf_evlist =3D *(struct evlist **)opt->value; - const struct pmu_event *table =3D pmu_events_table__find(); + const struct pmu_events_table *table =3D pmu_events_table__find(); =20 return parse_groups(perf_evlist, str, metric_no_group, metric_no_merge, NULL, metric_events, table); } =20 int metricgroup__parse_groups_test(struct evlist *evlist, - const struct pmu_event *table, + const struct pmu_events_table *table, const char *str, bool metric_no_group, bool metric_no_merge, @@ -1668,7 +1668,7 @@ int metricgroup__parse_groups_test(struct evlist *evl= ist, } =20 static int metricgroup__has_metric_callback(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *vdata) { const char *metric =3D vdata; @@ -1684,7 +1684,7 @@ static int metricgroup__has_metric_callback(const str= uct pmu_event *pe, =20 bool metricgroup__has_metric(const char *metric) { - const struct pmu_event *table =3D pmu_events_table__find(); + const struct pmu_events_table *table =3D pmu_events_table__find(); =20 if (!table) return false; diff --git a/tools/perf/util/metricgroup.h b/tools/perf/util/metricgroup.h index 5a1390e73d25..f54d170043e9 100644 --- a/tools/perf/util/metricgroup.h +++ b/tools/perf/util/metricgroup.h @@ -11,7 +11,6 @@ struct evlist; struct evsel; struct option; struct rblist; -struct pmu_events_map; struct cgroup; =20 /** @@ -71,9 +70,9 @@ int metricgroup__parse_groups(const struct option *opt, bool metric_no_merge, struct rblist *metric_events); const struct pmu_event *metricgroup__find_metric(const char *metric, - const struct pmu_event *table); + const struct pmu_events_table *table); int metricgroup__parse_groups_test(struct evlist *evlist, - const struct pmu_event *table, + const struct pmu_events_table *table, const char *str, bool metric_no_group, bool metric_no_merge, diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index dd1e171d7480..89655d53117a 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -710,7 +710,7 @@ char *perf_pmu__getcpuid(struct perf_pmu *pmu) return cpuid; } =20 -__weak const struct pmu_event *pmu_events_table__find(void) +__weak const struct pmu_events_table *pmu_events_table__find(void) { return perf_pmu__find_table(NULL); } @@ -799,7 +799,7 @@ struct pmu_add_cpu_aliases_map_data { }; =20 static int pmu_add_cpu_aliases_map_callback(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *vdata) { struct pmu_add_cpu_aliases_map_data *data =3D vdata; @@ -827,7 +827,7 @@ static int pmu_add_cpu_aliases_map_callback(const struc= t pmu_event *pe, * as aliases. */ void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pm= u, - const struct pmu_event *table) + const struct pmu_events_table *table) { struct pmu_add_cpu_aliases_map_data data =3D { .head =3D head, @@ -841,7 +841,7 @@ void pmu_add_cpu_aliases_table(struct list_head *head, = struct perf_pmu *pmu, =20 static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *p= mu) { - const struct pmu_event *table; + const struct pmu_events_table *table; =20 table =3D perf_pmu__find_table(pmu); if (!table) @@ -856,7 +856,7 @@ struct pmu_sys_event_iter_data { }; =20 static int pmu_add_sys_aliases_iter_fn(const struct pmu_event *pe, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *data) { struct pmu_sys_event_iter_data *idata =3D data; diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index f0aba1e462fa..a7b0f9507510 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -126,10 +126,10 @@ int perf_pmu__test(void); =20 struct perf_event_attr *perf_pmu__get_default_config(struct perf_pmu *pmu); void pmu_add_cpu_aliases_table(struct list_head *head, struct perf_pmu *pm= u, - const struct pmu_event *table); + const struct pmu_events_table *table); =20 char *perf_pmu__getcpuid(struct perf_pmu *pmu); -const struct pmu_event *pmu_events_table__find(void); +const struct pmu_events_table *pmu_events_table__find(void); bool pmu_uncore_alias_match(const char *pmu_name, const char *name); void perf_pmu_free_alias(struct perf_pmu_alias *alias); =20 diff --git a/tools/perf/util/s390-sample-raw.c b/tools/perf/util/s390-sampl= e-raw.c index 235319d45d02..9a631d97471c 100644 --- a/tools/perf/util/s390-sample-raw.c +++ b/tools/perf/util/s390-sample-raw.c @@ -135,7 +135,7 @@ struct get_counter_name_data { }; =20 static int get_counter_name_callback(const struct pmu_event *evp, - const struct pmu_event *table __maybe_unused, + const struct pmu_events_table *table __maybe_unused, void *vdata) { struct get_counter_name_data *data =3D vdata; @@ -157,7 +157,7 @@ static int get_counter_name_callback(const struct pmu_e= vent *evp, * the name of this counter. * If no match is found a NULL pointer is returned. */ -static const char *get_counter_name(int set, int nr, const struct pmu_even= t *table) +static const char *get_counter_name(int set, int nr, const struct pmu_even= ts_table *table) { struct get_counter_name_data data =3D { .wanted =3D get_counterset_start(set) + nr, @@ -177,7 +177,7 @@ static void s390_cpumcfdg_dump(struct perf_sample *samp= le) unsigned char *buf =3D sample->raw_data; const char *color =3D PERF_COLOR_BLUE; struct cf_ctrset_entry *cep, ce; - const struct pmu_event *table; + const struct pmu_events_table *table; u64 *p; =20 table =3D pmu_events_table__find(); --=20 2.37.1.595.g718a3a8f04-goog