Re: [PATCH v1] perf evlist: Force adding default events only to core PMUs

From: Leo Yan
Date: Mon May 27 2024 - 06:59:02 EST


On Sat, May 25, 2024 at 02:14:26PM -0700, Linus Torvalds wrote:
> On Sat, 25 May 2024 at 09:43, Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > This makes 'perf record' work for me again.
>
> Oh, wait, no it doesn't.
>
> It makes just the plain "perf record" without any arguments work,
> which was what I was testing because I was lazy.
>
> So now
>
> $ perf record sleep 1
>
> works fine. But
>
> $ perf record -e cycles:pp sleep 1
>
> is still completely broken (with or without ":p" and ":pp").

Seems to me that this patch fails to check if a PMU is a core-attached
PMU that can support common hardware events. Therefore, we should
consider adding the following check.

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 30f958069076..bc1822c2f3e3 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1594,6 +1594,9 @@ int parse_events_multi_pmu_add(struct parse_events_state *parse_state,
while ((pmu = perf_pmus__scan(pmu)) != NULL) {
bool auto_merge_stats;

+ if (hw_config != PERF_COUNT_HW_MAX && !pmu->is_core)
+ continue;
+
if (parse_events__filter_pmu(parse_state, pmu))
continue;

To be clear, I only compiled this change but I have no chance to test
it. @Ian, could you confirm this?

Thanks,
Leo


> So no. That still needs to be fixed, or the whole "prefer sysfs/JSON
> by default" needs to be reverted.