Re: [PATCH v4 6/6] perf c2c: print memory region data with stdio output
From: Ian Rogers
Date: Mon Aug 17 2026 - 17:40:00 EST
On Tue, Aug 11, 2026 at 10:34 AM Thomas Falcon <thomas.falcon@xxxxxxxxx> wrote:
>
> 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
>
> Assisted-by: Sashiko:gemini-3.1-pro-preview
> Signed-off-by: Thomas Falcon <thomas.falcon@xxxxxxxxx>
Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
I wonder about opportunities around this information and what is in
/proc/iomem as exposed in the mem-phys-addr.py script:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/scripts/python/mem-phys-addr.py?h=tmp.perf-tools-next
Thanks,
Ian
> ---
> v3: Included examples of memory range output in commit message
> ---
> 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 8cd90524fe49..7739023ced41 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
> @@ -2635,6 +2635,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();
> @@ -2648,6 +2676,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.55.0
>