[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAM9d7cipqHheaZOj9Qr56COjjdU2Qk1pLtUzkjZxtq4g3irLww@mail.gmail.com>
Date: Fri, 2 Feb 2024 17:50:20 -0800
From: Namhyung Kim <namhyung@...nel.org>
To: Adrian Hunter <adrian.hunter@...el.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>, Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>,
Like Xu <like.xu.linux@...il.com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH 1/2] perf script: Make it possible to see perf's kernel
and module memory mappings
On Fri, Feb 2, 2024 at 3:01 AM Adrian Hunter <adrian.hunter@...el.com> wrote:
>
> Dump kmaps if verbose > 2.
Maybe we can add '--debug kmap' option rather than using an
arbitrary verbose level.
Thanks,
Namhyung
>
> Example:
>
> $ perf script -vvv 2>&1 >/dev/null | grep kvm.intel
> build id event received for /lib/modules/6.7.2-local/kernel/arch/x86/kvm/kvm-intel.ko: 0691d75e10e72ebbbd45a44c59f6d00a5604badf [20]
> Map: 0-3a3 4f5d8 [kvm_intel].modinfo
> Map: 0-5240 5f280 [kvm_intel]__versions
> Map: 0-30 64 [kvm_intel].note.Linux
> Map: 0-14 644c0 [kvm_intel].orc_header
> Map: 0-5297 43680 [kvm_intel].rodata
> Map: 0-5bee 3b837 [kvm_intel].text.unlikely
> Map: 0-7e0 41430 [kvm_intel].noinstr.text
> Map: 0-2080 713c0 [kvm_intel].bss
> Map: 0-26 705c8 [kvm_intel].data..read_mostly
> Map: 0-5888 6a4c0 [kvm_intel].data
> Map: 0-22 70220 [kvm_intel].data.once
> Map: 0-40 705f0 [kvm_intel].data..percpu
> Map: 0-1685 41d20 [kvm_intel].init.text
> Map: 0-4b8 6fd60 [kvm_intel].init.data
> Map: 0-380 70248 [kvm_intel]__dyndbg
> Map: 0-8 70218 [kvm_intel].exit.data
> Map: 0-438 4f980 [kvm_intel]__param
> Map: 0-5f5 4ca0f [kvm_intel].rodata.str1.1
> Map: 0-3657 493b8 [kvm_intel].rodata.str1.8
> Map: 0-e0 70640 [kvm_intel].data..ro_after_init
> Map: 0-500 70ec0 [kvm_intel].gnu.linkonce.this_module
> Map: ffffffffc13a7000-ffffffffc1421000 a0 /lib/modules/6.7.2-local/kernel/arch/x86/kvm/kvm-intel.ko
>
> The example above shows how the module section mappings are all wrong
> except for the main .text mapping at 0xffffffffc13a7000.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
> ---
> tools/perf/builtin-script.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> index b1f57401ff23..e764b319ef59 100644
> --- a/tools/perf/builtin-script.c
> +++ b/tools/perf/builtin-script.c
> @@ -3806,6 +3806,16 @@ static int parse_callret_trace(const struct option *opt __maybe_unused,
> return 0;
> }
>
> +static void dump_kmaps(struct perf_session *session)
> +{
> + int save_verbose = verbose;
> +
> + pr_debug("Kernel and module maps:\n");
> + verbose = 0; /* Suppress verbose to print a summary only */
> + maps__fprintf(machine__kernel_maps(&session->machines.host), stderr);
> + verbose = save_verbose;
> +}
> +
> int cmd_script(int argc, const char **argv)
> {
> bool show_full_info = false;
> @@ -4366,6 +4376,9 @@ int cmd_script(int argc, const char **argv)
>
> flush_scripting();
>
> + if (verbose > 2)
> + dump_kmaps(session);
> +
> out_delete:
> if (script.ptime_range) {
> itrace_synth_opts__clear_time_range(&itrace_synth_opts);
> --
> 2.34.1
>
Powered by blists - more mailing lists