Support 'R' as a retirement latency modifier on events. When present
the evsel will fork perf record and perf report commands, parsing the
perf report output as the count value. The intent is to do something
similar to Weilin's series:
https://lore.kernel.org/lkml/[email protected]/
While the 'R' and the retirement latency are Intel specific, in the
future I can imagine more evsel like commands that require child
processes. We can make the logic more generic at that point.
The code is untested on hardware that supports retirement latency, and
with metrics with retirement latency in them. The record is also of
sleep and various things need tweaking but I think v1 is good enough
for people to give input.
The first patch stops opening a dummy event for tool events. I came
across this while looking into the issue and we can likely just pick
it first. I kept it in the series for cleanliness sake.
The code has benefitted greatly from Weilin's work and Namhyung's
great review input.
Ian Rogers (3):
perf evsel: Don't open tool events
perf parse-events: Add a retirement latency modifier
perf evsel: Add retirement latency event support
tools/perf/util/evsel.c | 186 ++++++++++++++++++++++++++++++++-
tools/perf/util/evsel.h | 4 +
tools/perf/util/parse-events.c | 2 +
tools/perf/util/parse-events.h | 1 +
tools/perf/util/parse-events.l | 3 +-
5 files changed, 192 insertions(+), 4 deletions(-)
--
2.44.0.769.g3c40516874-goog
Tool events are set up as software dummy events. Don't open them to
save some work and a file descriptor. The evsel's fds are initialized
to -1, so it suffices to just early return.
---
tools/perf/util/evsel.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 3536404e9447..2743d40665ff 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2005,6 +2005,11 @@ static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus,
int pid = -1, err, old_errno;
enum rlimit_action set_rlimit = NO_CHANGE;
+ if (evsel__is_tool(evsel)) {
+ /* Tool events are set up as dummy but don't need opening. */
+ return 0;
+ }
+
err = __evsel__prepare_open(evsel, cpus, threads);
if (err)
return err;
--
2.44.0.769.g3c40516874-goog
On 2024-04-25 6:34 p.m., Ian Rogers wrote:
> Support 'R' as a retirement latency modifier on events. When present
> the evsel will fork perf record and perf report commands, parsing the
> perf report output as the count value. The intent is to do something
> similar to Weilin's series:
> https://lore.kernel.org/lkml/[email protected]/
>
> While the 'R' and the retirement latency are Intel specific, in the
> future I can imagine more evsel like commands that require child
> processes. We can make the logic more generic at that point.
>
I think in generic what we want is the weight/latency information of the
event. 'W' is already occupied by the weak group. Maybe 'L' is a more
generic name than 'R'. With the event modifier, perf collects and report
the weight/latency information of the event in a perf stat command.
Not just changing the evsel, I think a proper output is still required.
It's possible that an end user can use it without metrics. E.g.,
perf stat -e cycles,instructions:L
A possible generic output maybe
1,931,099,931 cycles
801,826,458 instructions # Avg Weight1 1000
# Avg Weight2 800
# Avg Weight3 500
Thanks,
Kan
> The code is untested on hardware that supports retirement latency, and
> with metrics with retirement latency in them. The record is also of
> sleep and various things need tweaking but I think v1 is good enough
> for people to give input.
>
> The first patch stops opening a dummy event for tool events. I came
> across this while looking into the issue and we can likely just pick
> it first. I kept it in the series for cleanliness sake.
>
> The code has benefitted greatly from Weilin's work and Namhyung's
> great review input.
>
> Ian Rogers (3):
> perf evsel: Don't open tool events
> perf parse-events: Add a retirement latency modifier
> perf evsel: Add retirement latency event support
>
> tools/perf/util/evsel.c | 186 ++++++++++++++++++++++++++++++++-
> tools/perf/util/evsel.h | 4 +
> tools/perf/util/parse-events.c | 2 +
> tools/perf/util/parse-events.h | 1 +
> tools/perf/util/parse-events.l | 3 +-
> 5 files changed, 192 insertions(+), 4 deletions(-)
>