[PATCH v2 6/6] perf c2c: print memory region data with stdio output

From: Thomas Falcon

Date: Mon Jul 13 2026 - 20:45:28 EST


Print memory range data in perf-c2c subcommand. Only available in stdio
mode currently. If memory ranges are not supported or present, print
nothing.

Assisted-by: Sashiko:gemini-3.1-pro-preview
Signed-off-by: Thomas Falcon <thomas.falcon@xxxxxxxxx>
---
tools/perf/builtin-c2c.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index cba2e9f21ae7..68348a93bd33 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -2634,6 +2634,34 @@ static void print_c2c_info(FILE *out, struct perf_session *session)
fprintf(out, " Cacheline data grouping : %s\n", c2c.cl_sort);
}

+
+static void print_memory_ranges_info(FILE *out, struct perf_session *session)
+{
+ struct perf_env *env = perf_session__env(session);
+ int nr_ranges = 0;
+
+ if (!perf_header__has_feat(&session->header, HEADER_MEMORY_RANGES))
+ return;
+ nr_ranges = env->nr_memory_ranges;
+ if (nr_ranges == 0) {
+ pr_debug("No memory ranges found, skipping\n");
+ return;
+ }
+
+ fprintf(out, "\n");
+ fprintf(out, "=================================================\n");
+ fprintf(out, " Memory Ranges \n");
+ fprintf(out, "=================================================\n");
+
+ for (int i = 0; i < nr_ranges; i++) {
+ struct memory_range *r = &env->memory_ranges[i];
+
+ fprintf(out, "Range %d: [0x%016" PRIx64 "-0x%016" PRIx64 "] Node %d, local region id %u, remote region id %u\n",
+ i, r->base, r->base + r->length - 1, r->node,
+ r->local_region_id, r->remote_region_id);
+ }
+}
+
static void perf_c2c__hists_fprintf(FILE *out, struct perf_session *session)
{
setup_pager();
@@ -2647,6 +2675,8 @@ static void perf_c2c__hists_fprintf(FILE *out, struct perf_session *session)
if (c2c.stats_only)
return;

+ print_memory_ranges_info(out, session);
+
fprintf(out, "\n");
fprintf(out, "=================================================\n");
fprintf(out, " Shared Data Cache Line Table \n");
--
2.43.0