2022-06-07 12:37:26

by Xing Zhengjun

[permalink] [raw]
Subject: [PATCH 0/5] Add perf stat default events for hybrid machines

From: Zhengjun Xing <[email protected]>

The patch series is to clean up the existing perf stat default and support
the perf metrics Topdown for the p-core PMU in the perf stat default. The
first 4 patches are the clean-up patch and fixing the "--detailed" issue.
The last patch adds support for the perf metrics Topdown, the perf metrics
Topdown support for e-core PMU will be implemented later separately.

Kan Liang (4):
perf stat: Revert "perf stat: Add default hybrid events"
perf evsel: Add arch_evsel__hw_name()
perf evlist: Always use arch_evlist__add_default_attrs()
perf x86 evlist: Add default hybrid events for perf stat

Zhengjun Xing (1):
perf stat: Add topdown metrics in the default perf stat on the hybrid
machine

tools/perf/arch/x86/util/evlist.c | 64 +++++++++++++++++++++++++-----
tools/perf/arch/x86/util/evsel.c | 20 ++++++++++
tools/perf/arch/x86/util/topdown.c | 51 ++++++++++++++++++++++++
tools/perf/arch/x86/util/topdown.h | 1 +
tools/perf/builtin-stat.c | 50 ++++-------------------
tools/perf/util/evlist.c | 11 +++--
tools/perf/util/evlist.h | 9 ++++-
tools/perf/util/evsel.c | 7 +++-
tools/perf/util/evsel.h | 1 +
tools/perf/util/stat-display.c | 2 +-
tools/perf/util/topdown.c | 7 ++++
tools/perf/util/topdown.h | 3 +-
12 files changed, 166 insertions(+), 60 deletions(-)

--
2.25.1


2022-06-07 17:26:02

by Xing Zhengjun

[permalink] [raw]
Subject: [PATCH 1/5] perf stat: Revert "perf stat: Add default hybrid events"

From: Kan Liang <[email protected]>

This reverts commit ac2dc29edd21 ("perf stat: Add default hybrid
events").

Between this patch and the reverted patch, the commit 6c1912898ed2
("perf parse-events: Rename parse_events_error functions") and the
commit 07eafd4e053a ("perf parse-event: Add init and exit to
parse_event_error") clean up the parse_events_error_*() codes. The
related change is also reverted.

The reverted patch is hard to be extended to support new default
events, e.g., Topdown events, and the existing "--detailed" option
on a hybrid platform.

A new solution will be proposed in the following patch to enable the
perf stat default on a hybrid platform.

Signed-off-by: Kan Liang <[email protected]>
Signed-off-by: Zhengjun Xing <[email protected]>
---
tools/perf/builtin-stat.c | 30 ------------------------------
1 file changed, 30 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 4ce87a8eb7d7..6ac79d95f3b5 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1685,12 +1685,6 @@ static int add_default_attributes(void)
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES },

-};
- struct perf_event_attr default_sw_attrs[] = {
- { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_TASK_CLOCK },
- { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CONTEXT_SWITCHES },
- { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CPU_MIGRATIONS },
- { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS },
};

/*
@@ -1947,30 +1941,6 @@ static int add_default_attributes(void)
}

if (!evsel_list->core.nr_entries) {
- if (perf_pmu__has_hybrid()) {
- struct parse_events_error errinfo;
- const char *hybrid_str = "cycles,instructions,branches,branch-misses";
-
- if (target__has_cpu(&target))
- default_sw_attrs[0].config = PERF_COUNT_SW_CPU_CLOCK;
-
- if (evlist__add_default_attrs(evsel_list,
- default_sw_attrs) < 0) {
- return -1;
- }
-
- parse_events_error__init(&errinfo);
- err = parse_events(evsel_list, hybrid_str, &errinfo);
- if (err) {
- fprintf(stderr,
- "Cannot set up hybrid events %s: %d\n",
- hybrid_str, err);
- parse_events_error__print(&errinfo, hybrid_str);
- }
- parse_events_error__exit(&errinfo);
- return err ? -1 : 0;
- }
-
if (target__has_cpu(&target))
default_attrs0[0].config = PERF_COUNT_SW_CPU_CLOCK;

--
2.25.1