Skip to content

Commit 1eaf496

Browse files
captain5050acmel
authored andcommitted
perf pmu: Separate pmu and pmus
Separate and hide the pmus list in pmus.[ch]. Move pmus functionality out of pmu.[ch] into pmus.[ch] renaming pmus functions which were prefixed perf_pmu__ to perf_pmus__. Reviewed-by: Kan Liang <kan.liang@linux.intel.com> Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ali Saidi <alisaidi@amazon.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Dmitrii Dolgov <9erthalion6@gmail.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jing Zhang <renyu.zj@linux.alibaba.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kang Minchul <tegongkang@gmail.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Ming Wang <wangming01@loongson.cn> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Rob Herring <robh@kernel.org> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com> Cc: coresight@lists.linaro.org Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20230527072210.2900565-28-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 875375e commit 1eaf496

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+533
-506
lines changed

tools/perf/arch/arm/util/auxtrace.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "../../../util/debug.h"
1515
#include "../../../util/evlist.h"
1616
#include "../../../util/pmu.h"
17+
#include "../../../util/pmus.h"
1718
#include "cs-etm.h"
1819
#include "arm-spe.h"
1920
#include "hisi-ptt.h"
@@ -40,7 +41,7 @@ static struct perf_pmu **find_all_arm_spe_pmus(int *nr_spes, int *err)
4041
return NULL;
4142
}
4243

43-
arm_spe_pmus[*nr_spes] = perf_pmu__find(arm_spe_pmu_name);
44+
arm_spe_pmus[*nr_spes] = perf_pmus__find(arm_spe_pmu_name);
4445
if (arm_spe_pmus[*nr_spes]) {
4546
pr_debug2("%s %d: arm_spe_pmu %d type %d name %s\n",
4647
__func__, __LINE__, *nr_spes,
@@ -87,7 +88,7 @@ static struct perf_pmu **find_all_hisi_ptt_pmus(int *nr_ptts, int *err)
8788
rewinddir(dir);
8889
while ((dent = readdir(dir))) {
8990
if (strstr(dent->d_name, HISI_PTT_PMU_NAME) && idx < *nr_ptts) {
90-
hisi_ptt_pmus[idx] = perf_pmu__find(dent->d_name);
91+
hisi_ptt_pmus[idx] = perf_pmus__find(dent->d_name);
9192
if (hisi_ptt_pmus[idx])
9293
idx++;
9394
}
@@ -131,7 +132,7 @@ struct auxtrace_record
131132
if (!evlist)
132133
return NULL;
133134

134-
cs_etm_pmu = perf_pmu__find(CORESIGHT_ETM_PMU_NAME);
135+
cs_etm_pmu = perf_pmus__find(CORESIGHT_ETM_PMU_NAME);
135136
arm_spe_pmus = find_all_arm_spe_pmus(&nr_spes, err);
136137
hisi_ptt_pmus = find_all_hisi_ptt_pmus(&nr_ptts, err);
137138

tools/perf/arch/arm/util/cs-etm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "../../../util/evsel.h"
2626
#include "../../../util/perf_api_probe.h"
2727
#include "../../../util/evsel_config.h"
28-
#include "../../../util/pmu.h"
28+
#include "../../../util/pmus.h"
2929
#include "../../../util/cs-etm.h"
3030
#include <internal/lib.h> // page_size
3131
#include "../../../util/session.h"
@@ -881,7 +881,7 @@ struct auxtrace_record *cs_etm_record_init(int *err)
881881
struct perf_pmu *cs_etm_pmu;
882882
struct cs_etm_recording *ptr;
883883

884-
cs_etm_pmu = perf_pmu__find(CORESIGHT_ETM_PMU_NAME);
884+
cs_etm_pmu = perf_pmus__find(CORESIGHT_ETM_PMU_NAME);
885885

886886
if (!cs_etm_pmu) {
887887
*err = -EINVAL;

tools/perf/arch/arm64/util/pmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
#include <internal/cpumap.h>
44
#include "../../../util/cpumap.h"
55
#include "../../../util/pmu.h"
6+
#include "../../../util/pmus.h"
67
#include <api/fs/fs.h>
78
#include <math.h>
89

910
static struct perf_pmu *pmu__find_core_pmu(void)
1011
{
1112
struct perf_pmu *pmu = NULL;
1213

13-
while ((pmu = perf_pmu__scan(pmu))) {
14+
while ((pmu = perf_pmus__scan(pmu))) {
1415
if (!is_pmu_core(pmu->name))
1516
continue;
1617

tools/perf/arch/x86/tests/hybrid.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "evlist.h"
55
#include "evsel.h"
66
#include "pmu.h"
7+
#include "pmus.h"
78
#include "tests/tests.h"
89

910
static bool test_config(const struct evsel *evsel, __u64 expected_config)
@@ -113,7 +114,7 @@ static int test__hybrid_raw1(struct evlist *evlist)
113114
struct perf_evsel *evsel;
114115

115116
perf_evlist__for_each_evsel(&evlist->core, evsel) {
116-
struct perf_pmu *pmu = perf_pmu__find_by_type(evsel->attr.type);
117+
struct perf_pmu *pmu = perf_pmus__find_by_type(evsel->attr.type);
117118

118119
TEST_ASSERT_VAL("missing pmu", pmu);
119120
TEST_ASSERT_VAL("unexpected pmu", !strncmp(pmu->name, "cpu_", 4));
@@ -280,7 +281,7 @@ static int test_events(const struct evlist_test *events, int cnt)
280281

281282
int test__hybrid(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
282283
{
283-
if (!perf_pmu__has_hybrid())
284+
if (!perf_pmus__has_hybrid())
284285
return TEST_SKIP;
285286

286287
return test_events(test__hybrid_events, ARRAY_SIZE(test__hybrid_events));

tools/perf/arch/x86/util/auxtrace.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "../../../util/header.h"
1111
#include "../../../util/debug.h"
1212
#include "../../../util/pmu.h"
13+
#include "../../../util/pmus.h"
1314
#include "../../../util/auxtrace.h"
1415
#include "../../../util/intel-pt.h"
1516
#include "../../../util/intel-bts.h"
@@ -25,8 +26,8 @@ struct auxtrace_record *auxtrace_record__init_intel(struct evlist *evlist,
2526
bool found_pt = false;
2627
bool found_bts = false;
2728

28-
intel_pt_pmu = perf_pmu__find(INTEL_PT_PMU_NAME);
29-
intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME);
29+
intel_pt_pmu = perf_pmus__find(INTEL_PT_PMU_NAME);
30+
intel_bts_pmu = perf_pmus__find(INTEL_BTS_PMU_NAME);
3031

3132
evlist__for_each_entry(evlist, evsel) {
3233
if (intel_pt_pmu && evsel->core.attr.type == intel_pt_pmu->type)

tools/perf/arch/x86/util/evlist.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include <stdio.h>
33
#include "util/pmu.h"
4+
#include "util/pmus.h"
45
#include "util/evlist.h"
56
#include "util/parse-events.h"
67
#include "util/event.h"
@@ -17,7 +18,7 @@ static int ___evlist__add_default_attrs(struct evlist *evlist,
1718
for (i = 0; i < nr_attrs; i++)
1819
event_attr_init(attrs + i);
1920

20-
if (!perf_pmu__has_hybrid())
21+
if (!perf_pmus__has_hybrid())
2122
return evlist__add_attrs(evlist, attrs, nr_attrs);
2223

2324
for (i = 0; i < nr_attrs; i++) {
@@ -32,7 +33,7 @@ static int ___evlist__add_default_attrs(struct evlist *evlist,
3233
continue;
3334
}
3435

35-
while ((pmu = perf_pmu__scan(pmu)) != NULL) {
36+
while ((pmu = perf_pmus__scan(pmu)) != NULL) {
3637
struct perf_cpu_map *cpus;
3738
struct evsel *evsel;
3839

tools/perf/arch/x86/util/evsel.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "util/evsel.h"
55
#include "util/env.h"
66
#include "util/pmu.h"
7+
#include "util/pmus.h"
78
#include "linux/string.h"
89
#include "evsel.h"
910
#include "util/debug.h"
@@ -30,7 +31,7 @@ bool evsel__sys_has_perf_metrics(const struct evsel *evsel)
3031
* should be good enough to detect the perf metrics feature.
3132
*/
3233
if ((evsel->core.attr.type == PERF_TYPE_RAW) &&
33-
pmu_have_event(pmu_name, "slots"))
34+
perf_pmus__have_event(pmu_name, "slots"))
3435
return true;
3536

3637
return false;
@@ -98,8 +99,8 @@ void arch__post_evsel_config(struct evsel *evsel, struct perf_event_attr *attr)
9899
if (!evsel_pmu)
99100
return;
100101

101-
ibs_fetch_pmu = perf_pmu__find("ibs_fetch");
102-
ibs_op_pmu = perf_pmu__find("ibs_op");
102+
ibs_fetch_pmu = perf_pmus__find("ibs_fetch");
103+
ibs_op_pmu = perf_pmus__find("ibs_op");
103104

104105
if (ibs_fetch_pmu && ibs_fetch_pmu->type == evsel_pmu->type) {
105106
if (attr->config & IBS_FETCH_L3MISSONLY) {

tools/perf/arch/x86/util/intel-bts.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "../../../util/evlist.h"
1818
#include "../../../util/mmap.h"
1919
#include "../../../util/session.h"
20-
#include "../../../util/pmu.h"
20+
#include "../../../util/pmus.h"
2121
#include "../../../util/debug.h"
2222
#include "../../../util/record.h"
2323
#include "../../../util/tsc.h"
@@ -416,7 +416,7 @@ static int intel_bts_find_snapshot(struct auxtrace_record *itr, int idx,
416416

417417
struct auxtrace_record *intel_bts_recording_init(int *err)
418418
{
419-
struct perf_pmu *intel_bts_pmu = perf_pmu__find(INTEL_BTS_PMU_NAME);
419+
struct perf_pmu *intel_bts_pmu = perf_pmus__find(INTEL_BTS_PMU_NAME);
420420
struct intel_bts_recording *btsr;
421421

422422
if (!intel_bts_pmu)

tools/perf/arch/x86/util/intel-pt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "../../../util/mmap.h"
2424
#include <subcmd/parse-options.h>
2525
#include "../../../util/parse-events.h"
26-
#include "../../../util/pmu.h"
26+
#include "../../../util/pmus.h"
2727
#include "../../../util/debug.h"
2828
#include "../../../util/auxtrace.h"
2929
#include "../../../util/perf_api_probe.h"
@@ -1185,7 +1185,7 @@ static u64 intel_pt_reference(struct auxtrace_record *itr __maybe_unused)
11851185

11861186
struct auxtrace_record *intel_pt_recording_init(int *err)
11871187
{
1188-
struct perf_pmu *intel_pt_pmu = perf_pmu__find(INTEL_PT_PMU_NAME);
1188+
struct perf_pmu *intel_pt_pmu = perf_pmus__find(INTEL_PT_PMU_NAME);
11891189
struct intel_pt_recording *ptr;
11901190

11911191
if (!intel_pt_pmu)

tools/perf/arch/x86/util/mem-events.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
22
#include "util/pmu.h"
3+
#include "util/pmus.h"
34
#include "util/env.h"
45
#include "map_symbol.h"
56
#include "mem-events.h"
@@ -55,12 +56,12 @@ struct perf_mem_event *perf_mem_events__ptr(int i)
5556

5657
bool is_mem_loads_aux_event(struct evsel *leader)
5758
{
58-
struct perf_pmu *pmu = perf_pmu__find("cpu");
59+
struct perf_pmu *pmu = perf_pmus__find("cpu");
5960

6061
if (!pmu)
61-
pmu = perf_pmu__find("cpu_core");
62+
pmu = perf_pmus__find("cpu_core");
6263

63-
if (pmu && !pmu_have_event(pmu->name, "mem-loads-aux"))
64+
if (pmu && !perf_pmu__have_event(pmu, "mem-loads-aux"))
6465
return false;
6566

6667
return leader->core.attr.config == MEM_LOADS_AUX;
@@ -82,7 +83,7 @@ char *perf_mem_events__name(int i, char *pmu_name)
8283
pmu_name = (char *)"cpu";
8384
}
8485

85-
if (pmu_have_event(pmu_name, "mem-loads-aux")) {
86+
if (perf_pmus__have_event(pmu_name, "mem-loads-aux")) {
8687
scnprintf(mem_loads_name, sizeof(mem_loads_name),
8788
MEM_LOADS_AUX_NAME, pmu_name, pmu_name,
8889
perf_mem_events__loads_ldlat);

0 commit comments

Comments
 (0)