Skip to content

Commit 240505b

Browse files
captain5050namhyung
authored andcommitted
perf tool_pmu: Factor tool events into their own PMU
Rather than treat tool events as a special kind of event, create a tool only PMU where the events/aliases match the existing duration_time, user_time and system_time events. Remove special parsing and printing support for the tool events, but add function calls for when PMU functions are called on a tool_pmu. Move the tool PMU code in evsel into tool_pmu.c to better encapsulate the tool event behavior in that file. Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20241002032016.333748-5-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent d2f3ecb commit 240505b

19 files changed

+530
-392
lines changed

tools/perf/builtin-list.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "util/string2.h"
2020
#include "util/strlist.h"
2121
#include "util/strbuf.h"
22+
#include "util/tool_pmu.h"
2223
#include <subcmd/pager.h>
2324
#include <subcmd/parse-options.h>
2425
#include <linux/zalloc.h>
@@ -614,9 +615,18 @@ int cmd_list(int argc, const char **argv)
614615
event_symbols_hw, PERF_COUNT_HW_MAX);
615616
else if (strcmp(argv[i], "sw") == 0 ||
616617
strcmp(argv[i], "software") == 0) {
618+
char *old_pmu_glob = default_ps.pmu_glob;
619+
617620
print_symbol_events(&print_cb, ps, PERF_TYPE_SOFTWARE,
618621
event_symbols_sw, PERF_COUNT_SW_MAX);
619-
print_tool_events(&print_cb, ps);
622+
default_ps.pmu_glob = strdup("tool");
623+
if (!default_ps.pmu_glob) {
624+
ret = -1;
625+
goto out;
626+
}
627+
perf_pmus__print_pmu_events(&print_cb, ps);
628+
zfree(&default_ps.pmu_glob);
629+
default_ps.pmu_glob = old_pmu_glob;
620630
} else if (strcmp(argv[i], "cache") == 0 ||
621631
strcmp(argv[i], "hwcache") == 0)
622632
print_hwcache_events(&print_cb, ps);
@@ -664,7 +674,6 @@ int cmd_list(int argc, const char **argv)
664674
event_symbols_hw, PERF_COUNT_HW_MAX);
665675
print_symbol_events(&print_cb, ps, PERF_TYPE_SOFTWARE,
666676
event_symbols_sw, PERF_COUNT_SW_MAX);
667-
print_tool_events(&print_cb, ps);
668677
print_hwcache_events(&print_cb, ps);
669678
perf_pmus__print_pmu_events(&print_cb, ps);
670679
print_tracepoint_events(&print_cb, ps);

tools/perf/builtin-stat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "util/parse-events.h"
4747
#include "util/pmus.h"
4848
#include "util/pmu.h"
49+
#include "util/tool_pmu.h"
4950
#include "util/event.h"
5051
#include "util/evlist.h"
5152
#include "util/evsel.h"

tools/perf/util/Build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ perf-util-y += pmu.o
8383
perf-util-y += pmus.o
8484
perf-util-y += pmu-flex.o
8585
perf-util-y += pmu-bison.o
86+
perf-util-y += tool_pmu.o
8687
perf-util-y += svghelper.o
8788
perf-util-$(CONFIG_LIBTRACEEVENT) += trace-event-info.o
8889
perf-util-y += trace-event-scripting.o

0 commit comments

Comments
 (0)