[RFC PATCH 0/1] libperf: evlist: Fix --cpu argument on hybrid platform
From: James Clark
Date: Tue Oct 15 2024 - 10:57:42 EST
I noticed that this isn't working on Arm or Intel, and I've attached a
hack that I don't really think is the right fix but it does work. It's
not strictly a regression from the linked fixes: commit, as before that
events wouldn't be opened on multiple PMUs properly. But after it the
error becomes more fatal.
Posting the RFC because whatever the fix should be isn't straightforward
and probably needs discussion. I think similar things have been
discussed before about the empty cpumap issue, but not related to the
--cpu option.
I thought of a few possible fixes:
* Don't open "empty" CPU maps in Perf. This would make Perf and libperf
diverge. Also not sure if libperf is supposed to be backwards
compatible? But this would be a breaking change because someone might
be using empty == all deliberately.
* Prune the evlist for empty CPU maps in every tool in Perf. This isn't
great because users of libperf also have to do this and is a lot of
duplication in Perf.
* Use cpumap->nr == 0 for empty instead of cpumap == NULL
One issue with the attached fix is that you can only delete the core
evsel from within libperf and not Perf's part of it. Also maybe it's a
bit weird for the propagate function to start deleting things.
For reference the empty to any code is here:
static int __evsel__prepare_open(...)
if (cpus == NULL) {
if (empty_cpu_map == NULL) {
empty_cpu_map = perf_cpu_map__new_any_cpu();
if (empty_cpu_map == NULL)
return -ENOMEM;
}
cpus = empty_cpu_map;
}
James Clark (1):
libperf: evlist: Fix --cpu argument on hybrid platform
tools/lib/perf/evlist.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
--
2.34.1