mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 01:53:29 +02:00
perf list: Remove tracepoint printing code
Now that the tp_pmu can iterate and describe events remove the custom tracepoint printing logic, this avoids perf list showing the tracepoint events twice. Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Link: https://lore.kernel.org/r/20250725185202.68671-7-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
45b6e281cb
commit
55c09681cc
|
|
@ -614,9 +614,18 @@ int cmd_list(int argc, const char **argv)
|
|||
for (i = 0; i < argc; ++i) {
|
||||
char *sep, *s;
|
||||
|
||||
if (strcmp(argv[i], "tracepoint") == 0)
|
||||
print_tracepoint_events(&print_cb, ps);
|
||||
else if (strcmp(argv[i], "hw") == 0 ||
|
||||
if (strcmp(argv[i], "tracepoint") == 0) {
|
||||
char *old_pmu_glob = default_ps.pmu_glob;
|
||||
|
||||
default_ps.pmu_glob = strdup("tracepoint");
|
||||
if (!default_ps.pmu_glob) {
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
perf_pmus__print_pmu_events(&print_cb, ps);
|
||||
zfree(&default_ps.pmu_glob);
|
||||
default_ps.pmu_glob = old_pmu_glob;
|
||||
} else if (strcmp(argv[i], "hw") == 0 ||
|
||||
strcmp(argv[i], "hardware") == 0)
|
||||
print_symbol_events(&print_cb, ps, PERF_TYPE_HARDWARE,
|
||||
event_symbols_hw, PERF_COUNT_HW_MAX);
|
||||
|
|
@ -658,6 +667,7 @@ int cmd_list(int argc, const char **argv)
|
|||
#endif
|
||||
else if ((sep = strchr(argv[i], ':')) != NULL) {
|
||||
char *old_pmu_glob = default_ps.pmu_glob;
|
||||
char *old_event_glob = default_ps.event_glob;
|
||||
|
||||
default_ps.event_glob = strdup(argv[i]);
|
||||
if (!default_ps.event_glob) {
|
||||
|
|
@ -665,13 +675,21 @@ int cmd_list(int argc, const char **argv)
|
|||
goto out;
|
||||
}
|
||||
|
||||
print_tracepoint_events(&print_cb, ps);
|
||||
default_ps.pmu_glob = strdup("tracepoint");
|
||||
if (!default_ps.pmu_glob) {
|
||||
zfree(&default_ps.event_glob);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
perf_pmus__print_pmu_events(&print_cb, ps);
|
||||
zfree(&default_ps.pmu_glob);
|
||||
default_ps.pmu_glob = old_pmu_glob;
|
||||
print_sdt_events(&print_cb, ps);
|
||||
default_ps.metrics = true;
|
||||
default_ps.metricgroups = true;
|
||||
metricgroup__print(&print_cb, ps);
|
||||
zfree(&default_ps.event_glob);
|
||||
default_ps.pmu_glob = old_pmu_glob;
|
||||
default_ps.event_glob = old_event_glob;
|
||||
} else {
|
||||
if (asprintf(&s, "*%s*", argv[i]) < 0) {
|
||||
printf("Critical: Not enough memory! Trying to continue...\n");
|
||||
|
|
@ -682,7 +700,6 @@ int cmd_list(int argc, const char **argv)
|
|||
event_symbols_hw, PERF_COUNT_HW_MAX);
|
||||
print_hwcache_events(&print_cb, ps);
|
||||
perf_pmus__print_pmu_events(&print_cb, ps);
|
||||
print_tracepoint_events(&print_cb, ps);
|
||||
print_sdt_events(&print_cb, ps);
|
||||
default_ps.metrics = true;
|
||||
default_ps.metricgroups = true;
|
||||
|
|
|
|||
|
|
@ -44,97 +44,6 @@ static const char * const event_type_descriptors[] = {
|
|||
"Hardware breakpoint",
|
||||
};
|
||||
|
||||
/*
|
||||
* Print the events from <debugfs_mount_point>/tracing/events
|
||||
*/
|
||||
void print_tracepoint_events(const struct print_callbacks *print_cb __maybe_unused, void *print_state __maybe_unused)
|
||||
{
|
||||
char *events_path = get_tracing_file("events");
|
||||
int events_fd = open(events_path, O_PATH);
|
||||
struct dirent **sys_namelist = NULL;
|
||||
int sys_items;
|
||||
|
||||
if (events_fd < 0) {
|
||||
pr_err("Error: failed to open tracing events directory\n");
|
||||
pr_err("%s: %s\n", events_path, strerror(errno));
|
||||
return;
|
||||
}
|
||||
put_tracing_file(events_path);
|
||||
|
||||
sys_items = tracing_events__scandir_alphasort(&sys_namelist);
|
||||
|
||||
for (int i = 0; i < sys_items; i++) {
|
||||
struct dirent *sys_dirent = sys_namelist[i];
|
||||
struct dirent **evt_namelist = NULL;
|
||||
int dir_fd;
|
||||
int evt_items;
|
||||
|
||||
if (sys_dirent->d_type != DT_DIR ||
|
||||
!strcmp(sys_dirent->d_name, ".") ||
|
||||
!strcmp(sys_dirent->d_name, ".."))
|
||||
goto next_sys;
|
||||
|
||||
dir_fd = openat(events_fd, sys_dirent->d_name, O_PATH);
|
||||
if (dir_fd < 0)
|
||||
goto next_sys;
|
||||
|
||||
evt_items = scandirat(events_fd, sys_dirent->d_name, &evt_namelist, NULL, alphasort);
|
||||
for (int j = 0; j < evt_items; j++) {
|
||||
/*
|
||||
* Buffer sized at twice the max filename length + 1
|
||||
* separator + 1 \0 terminator.
|
||||
*/
|
||||
char buf[NAME_MAX * 2 + 2];
|
||||
/* 16 possible hex digits and 22 other characters and \0. */
|
||||
char encoding[16 + 22];
|
||||
struct dirent *evt_dirent = evt_namelist[j];
|
||||
struct io id;
|
||||
__u64 config;
|
||||
|
||||
if (evt_dirent->d_type != DT_DIR ||
|
||||
!strcmp(evt_dirent->d_name, ".") ||
|
||||
!strcmp(evt_dirent->d_name, ".."))
|
||||
goto next_evt;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/id", evt_dirent->d_name);
|
||||
io__init(&id, openat(dir_fd, buf, O_RDONLY), buf, sizeof(buf));
|
||||
|
||||
if (id.fd < 0)
|
||||
goto next_evt;
|
||||
|
||||
if (io__get_dec(&id, &config) < 0) {
|
||||
close(id.fd);
|
||||
goto next_evt;
|
||||
}
|
||||
close(id.fd);
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s:%s",
|
||||
sys_dirent->d_name, evt_dirent->d_name);
|
||||
snprintf(encoding, sizeof(encoding), "tracepoint/config=0x%llx/", config);
|
||||
print_cb->print_event(print_state,
|
||||
/*topic=*/NULL,
|
||||
/*pmu_name=*/NULL, /* really "tracepoint" */
|
||||
/*event_name=*/buf,
|
||||
/*event_alias=*/NULL,
|
||||
/*scale_unit=*/NULL,
|
||||
/*deprecated=*/false,
|
||||
"Tracepoint event",
|
||||
/*desc=*/NULL,
|
||||
/*long_desc=*/NULL,
|
||||
encoding);
|
||||
next_evt:
|
||||
free(evt_namelist[j]);
|
||||
}
|
||||
close(dir_fd);
|
||||
free(evt_namelist);
|
||||
next_sys:
|
||||
free(sys_namelist[i]);
|
||||
}
|
||||
|
||||
free(sys_namelist);
|
||||
close(events_fd);
|
||||
}
|
||||
|
||||
void print_sdt_events(const struct print_callbacks *print_cb, void *print_state)
|
||||
{
|
||||
struct strlist *bidlist, *sdtlist;
|
||||
|
|
@ -552,8 +461,6 @@ void print_events(const struct print_callbacks *print_cb, void *print_state)
|
|||
/*long_desc=*/NULL,
|
||||
/*encoding_desc=*/NULL);
|
||||
|
||||
print_tracepoint_events(print_cb, print_state);
|
||||
|
||||
print_sdt_events(print_cb, print_state);
|
||||
|
||||
metricgroup__print(print_cb, print_state);
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@ void print_sdt_events(const struct print_callbacks *print_cb, void *print_state)
|
|||
void print_symbol_events(const struct print_callbacks *print_cb, void *print_state,
|
||||
unsigned int type, const struct event_symbol *syms,
|
||||
unsigned int max);
|
||||
|
||||
void print_tracepoint_events(const struct print_callbacks *print_cb, void *print_state);
|
||||
void metricgroup__print(const struct print_callbacks *print_cb, void *print_state);
|
||||
bool is_event_supported(u8 type, u64 config);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user