Skip to content

Commit 94f9eb9

Browse files
captain5050acmel
authored andcommitted
perf pmus: Remove perf_pmus__has_hybrid
perf_pmus__has_hybrid was used to detect when there was >1 core PMU, this can be achieved with perf_pmus__num_core_pmus that doesn't depend upon is_pmu_hybrid and PMU name comparisons. When modifying the function calls take the opportunity to improve comments, enable/simplify tests that were previously failing for hybrid but now pass and to simplify generic code. 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-34-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 002c484 commit 94f9eb9

File tree

17 files changed

+31
-80
lines changed

17 files changed

+31
-80
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ static int test_events(const struct evlist_test *events, int cnt)
281281

282282
int test__hybrid(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
283283
{
284-
if (!perf_pmus__has_hybrid())
284+
if (perf_pmus__num_core_pmus() == 1)
285285
return TEST_SKIP;
286286

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static int ___evlist__add_default_attrs(struct evlist *evlist,
1818
for (i = 0; i < nr_attrs; i++)
1919
event_attr_init(attrs + i);
2020

21-
if (!perf_pmus__has_hybrid())
21+
if (perf_pmus__num_core_pmus() == 1)
2222
return evlist__add_attrs(evlist, attrs, nr_attrs);
2323

2424
for (i = 0; i < nr_attrs; i++) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ uint64_t arch__intr_reg_mask(void)
292292
*/
293293
attr.sample_period = 1;
294294

295-
if (perf_pmus__has_hybrid()) {
295+
if (perf_pmus__num_core_pmus() > 1) {
296296
struct perf_pmu *pmu = NULL;
297297
__u64 type = PERF_TYPE_RAW;
298298

tools/perf/builtin-record.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ static int record__open(struct record *rec)
12941294
* of waiting or event synthesis.
12951295
*/
12961296
if (opts->target.initial_delay || target__has_cpu(&opts->target) ||
1297-
perf_pmus__has_hybrid()) {
1297+
perf_pmus__num_core_pmus() > 1) {
12981298
pos = evlist__get_tracking_event(evlist);
12991299
if (!evsel__is_dummy_event(pos)) {
13001300
/* Set up dummy event. */
@@ -2193,7 +2193,7 @@ static void record__uniquify_name(struct record *rec)
21932193
char *new_name;
21942194
int ret;
21952195

2196-
if (!perf_pmus__has_hybrid())
2196+
if (perf_pmus__num_core_pmus() == 1)
21972197
return;
21982198

21992199
evlist__for_each_entry(evlist, pos) {

tools/perf/tests/attr.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,15 @@ static int test__attr(struct test_suite *test __maybe_unused, int subtest __mayb
185185
char path_dir[PATH_MAX];
186186
char *exec_path;
187187

188-
if (perf_pmus__has_hybrid())
188+
if (perf_pmus__num_core_pmus() > 1) {
189+
/*
190+
* TODO: Attribute tests hard code the PMU type. If there are >1
191+
* core PMU then each PMU will have a different type whic
192+
* requires additional support.
193+
*/
194+
pr_debug("Skip test on hybrid systems");
189195
return TEST_SKIP;
196+
}
190197

191198
/* First try development tree tests. */
192199
if (!lstat("./tests", &st))

tools/perf/tests/parse-metric.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,8 @@ static int test__parse_metric(struct test_suite *test __maybe_unused, int subtes
302302
TEST_ASSERT_VAL("DCache_L2 failed", test_dcache_l2() == 0);
303303
TEST_ASSERT_VAL("recursion fail failed", test_recursion_fail() == 0);
304304
TEST_ASSERT_VAL("Memory bandwidth", test_memory_bandwidth() == 0);
305-
306-
if (!perf_pmus__has_hybrid()) {
307-
TEST_ASSERT_VAL("cache_miss_cycles failed", test_cache_miss_cycles() == 0);
308-
TEST_ASSERT_VAL("test metric group", test_metric_group() == 0);
309-
}
305+
TEST_ASSERT_VAL("cache_miss_cycles failed", test_cache_miss_cycles() == 0);
306+
TEST_ASSERT_VAL("test metric group", test_metric_group() == 0);
310307
return 0;
311308
}
312309

tools/perf/tests/switch-tracking.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -375,17 +375,7 @@ static int test__switch_tracking(struct test_suite *test __maybe_unused, int sub
375375
cpu_clocks_evsel = evlist__last(evlist);
376376

377377
/* Second event */
378-
if (perf_pmus__has_hybrid()) {
379-
cycles = "cpu_core/cycles/u";
380-
err = parse_event(evlist, cycles);
381-
if (err) {
382-
cycles = "cpu_atom/cycles/u";
383-
pr_debug("Trying %s\n", cycles);
384-
err = parse_event(evlist, cycles);
385-
}
386-
} else {
387-
err = parse_event(evlist, cycles);
388-
}
378+
err = parse_event(evlist, cycles);
389379
if (err) {
390380
pr_debug("Failed to parse event %s\n", cycles);
391381
goto out_err;

tools/perf/tests/topology.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,8 @@ static int session_write_header(char *path)
4141
session = perf_session__new(&data, NULL);
4242
TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
4343

44-
if (!perf_pmus__has_hybrid()) {
45-
session->evlist = evlist__new_default();
46-
TEST_ASSERT_VAL("can't get evlist", session->evlist);
47-
} else {
48-
struct parse_events_error err;
49-
50-
session->evlist = evlist__new();
51-
TEST_ASSERT_VAL("can't get evlist", session->evlist);
52-
parse_events_error__init(&err);
53-
parse_events(session->evlist, "cpu_core/cycles/", &err);
54-
parse_events_error__exit(&err);
55-
}
44+
session->evlist = evlist__new_default();
45+
TEST_ASSERT_VAL("can't get evlist", session->evlist);
5646

5747
perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
5848
perf_header__set_feat(&session->header, HEADER_NRCPUS);

tools/perf/util/cputopo.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,9 @@ struct hybrid_topology *hybrid_topology__new(void)
472472
{
473473
struct perf_pmu *pmu = NULL;
474474
struct hybrid_topology *tp = NULL;
475-
u32 nr = 0, i = 0;
475+
int nr = perf_pmus__num_core_pmus(), i = 0;
476476

477-
if (!perf_pmus__has_hybrid())
478-
return NULL;
479-
480-
while ((pmu = perf_pmus__scan_core(pmu)) != NULL)
481-
nr++;
482-
483-
if (nr == 0)
477+
if (nr <= 1)
484478
return NULL;
485479

486480
tp = zalloc(sizeof(*tp) + sizeof(tp->nodes[0]) * nr);

tools/perf/util/evsel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3140,7 +3140,7 @@ void evsel__zero_per_pkg(struct evsel *evsel)
31403140
*/
31413141
bool evsel__is_hybrid(const struct evsel *evsel)
31423142
{
3143-
if (!perf_pmus__has_hybrid())
3143+
if (perf_pmus__num_core_pmus() == 1)
31443144
return false;
31453145

31463146
return evsel->core.is_pmu_core;

0 commit comments

Comments
 (0)