Commit 525615ef authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

perf list: Add tracepoint encoding to detailed output

The tracepoint id holds the config value and is probed in determining
what an event is. Add reading of the id so that we can display the
event encoding as:

  $ perf list --details
  ...
    alarmtimer:alarmtimer_cancel                       [Tracepoint event]
          tracepoint/config=0x18c/
  ...
Signed-off-by: default avatarIan Rogers <irogers@google.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: default avatarKan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/r/20240308001915.4060155-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 2316ef58
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <unistd.h> #include <unistd.h>
#include <api/fs/tracing_path.h> #include <api/fs/tracing_path.h>
#include <api/io.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
...@@ -92,34 +93,48 @@ void print_tracepoint_events(const struct print_callbacks *print_cb __maybe_unus ...@@ -92,34 +93,48 @@ void print_tracepoint_events(const struct print_callbacks *print_cb __maybe_unus
evt_items = scandirat(events_fd, sys_dirent->d_name, &evt_namelist, NULL, alphasort); evt_items = scandirat(events_fd, sys_dirent->d_name, &evt_namelist, NULL, alphasort);
for (int j = 0; j < evt_items; j++) { 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 dirent *evt_dirent = evt_namelist[j];
char evt_path[MAXPATHLEN]; struct io id;
int evt_fd; __u64 config;
if (evt_dirent->d_type != DT_DIR || if (evt_dirent->d_type != DT_DIR ||
!strcmp(evt_dirent->d_name, ".") || !strcmp(evt_dirent->d_name, ".") ||
!strcmp(evt_dirent->d_name, "..")) !strcmp(evt_dirent->d_name, ".."))
goto next_evt; goto next_evt;
snprintf(evt_path, sizeof(evt_path), "%s/id", evt_dirent->d_name); snprintf(buf, sizeof(buf), "%s/id", evt_dirent->d_name);
evt_fd = openat(dir_fd, evt_path, O_RDONLY); io__init(&id, openat(dir_fd, buf, O_RDONLY), buf, sizeof(buf));
if (evt_fd < 0)
if (id.fd < 0)
goto next_evt; goto next_evt;
close(evt_fd);
snprintf(evt_path, MAXPATHLEN, "%s:%s", 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); sys_dirent->d_name, evt_dirent->d_name);
snprintf(encoding, sizeof(encoding), "tracepoint/config=0x%llx/", config);
print_cb->print_event(print_state, print_cb->print_event(print_state,
/*topic=*/NULL, /*topic=*/NULL,
/*pmu_name=*/NULL, /*pmu_name=*/NULL, /* really "tracepoint" */
evt_path, /*event_name=*/buf,
/*event_alias=*/NULL, /*event_alias=*/NULL,
/*scale_unit=*/NULL, /*scale_unit=*/NULL,
/*deprecated=*/false, /*deprecated=*/false,
"Tracepoint event", "Tracepoint event",
/*desc=*/NULL, /*desc=*/NULL,
/*long_desc=*/NULL, /*long_desc=*/NULL,
/*encoding_desc=*/NULL); encoding);
next_evt: next_evt:
free(evt_namelist[j]); free(evt_namelist[j]);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment