2021-03-16 20:47:30

by Dan Schatzberg

[permalink] [raw]
Subject: [PATCH 0/1] Display raw event in perf mem report

In doing some memory trace analysis I've noticed a lack of a way to
disambiguate loads from stores in perf mem report. In order to address
this I've added the raw event name to the output.

Please let me know if there's some better way to achieve this instead.

Dan Schatzberg (1):
perf: display raw event for mem report

tools/perf/builtin-mem.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

--
2.30.2


2021-03-16 20:48:25

by Dan Schatzberg

[permalink] [raw]
Subject: [PATCH 1/1] perf: display raw event for mem report

`perf mem record` can be used to capture memory loads/stores using
PEBS counters. `perf mem report -D` can be used to dump the raw
samples (e.g. each sampled memory access). However, it does not output
the raw event (load vs store).

This patch supplements the output of `perf mem report -D` with the
event name.

Signed-off-by: Dan Schatzberg <[email protected]>
---
tools/perf/builtin-mem.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index cdd2b9f643f6..1f4ec350bca3 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -172,6 +172,7 @@ static int
dump_raw_samples(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
+ struct evsel *evsel,
struct machine *machine)
{
struct perf_mem *mem = container_of(tool, struct perf_mem, tool);
@@ -220,6 +221,11 @@ dump_raw_samples(struct perf_tool *tool,
symbol_conf.field_sep);
}

+ if (evsel->name)
+ printf("%s%s", evsel->name, symbol_conf.field_sep);
+ else
+ printf("%s", symbol_conf.field_sep);
+
if (field_sep)
fmt = "%"PRIu64"%s0x%"PRIx64"%s%s:%s\n";
else
@@ -240,10 +246,10 @@ dump_raw_samples(struct perf_tool *tool,
static int process_sample_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
- struct evsel *evsel __maybe_unused,
+ struct evsel *evsel,
struct machine *machine)
{
- return dump_raw_samples(tool, event, sample, machine);
+ return dump_raw_samples(tool, event, sample, evsel, machine);
}

static int report_raw_events(struct perf_mem *mem)
@@ -287,7 +293,7 @@ static int report_raw_events(struct perf_mem *mem)
if (mem->data_page_size)
printf("DATA PAGE SIZE, ");

- printf("LOCAL WEIGHT, DSRC, SYMBOL\n");
+ printf("EVENT, LOCAL WEIGHT, DSRC, SYMBOL\n");

ret = perf_session__process_events(session);

--
2.30.2