perf c2c: Print memory region data with stdio output

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

Example output of perf c2c report --stdio:

=================================================
                  Memory Ranges
=================================================
Range 0: [0x0000000000000000-0x00000000bfffffff] Node 0, local region id 0, remote region id 255
Range 1: [0x0000000100000000-0x000000203fffffff] Node 0, local region id 0, remote region id 255
Range 2: [0x0000008000000000-0x0000027fffffffff] Node -2, local region id 1, remote region id 255
Range 3: [0x0000028000000000-0x0000047fffffffff] Node -2, local region id 1, remote region id 255
Range 4: [0x0000048000000000-0x000004ffffffffff] Node -2, local region id 1, remote region id 255

Reviewed-by: Ian Rogers <irogers@google.com>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Assisted-by: Sashiko:gemini-3.1-pro-preview
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Thomas Falcon 2026-09-23 12:09:03 -05:00 committed by Arnaldo Carvalho de Melo
parent 8eca6fa643
commit dd0b7ec38d

View File

@ -2597,6 +2597,33 @@ 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();
@ -2610,6 +2637,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");