Skip to contentSkip to conversation

Display raw event in perf mem report

PATCH New Dan Schatzberg 1 participant 2 messages Mar 16, 2021 perf events

lore
Share & tools
lore
#0 lore raw

cover 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(-)
Signature · 1 line
2.30.2
#1 lore raw

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.

---
 tools/perf/builtin-mem.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/builtin-mem.c +9 -3
index cdd2b9f643f6..1f4ec350bca3 100644
@@ -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);
 
Signature · 1 line
2.30.2