linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	 Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
	Like Xu <like.xu.linux@gmail.com>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	 linux-perf-users <linux-perf-users@vger.kernel.org>
Subject: Re: [PATCH 1/2] perf script: Make it possible to see perf's kernel and module memory mappings
Date: Mon, 5 Feb 2024 18:21:07 -0800	[thread overview]
Message-ID: <CAM9d7chXSvhej4Evaq1gS_g-zPd0jOVBQDh3UmKAaE2UvP7-Hw@mail.gmail.com> (raw)
In-Reply-To: <4983cc09-20ad-450b-8eba-219f75a5fab2@intel.com>

On Sun, Feb 4, 2024 at 11:08 PM Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 3/02/24 03:56, Arnaldo Carvalho de Melo wrote:
> >
> >
> > On Fri, Feb 2, 2024, 10:50 PM Namhyung Kim <namhyung@kernel.org <mailto:namhyung@kernel.org>> wrote:
> >
> >     On Fri, Feb 2, 2024 at 3:01 AM Adrian Hunter <adrian.hunter@intel.com <mailto:adrian.hunter@intel.com>> wrote:
> >     >
> >     > Dump kmaps if verbose > 2.
> >
> >     Maybe we can add '--debug kmap' option rather than using an
> >     arbitrary verbose level.
>
> That is a global option but would only work for tools that are
> explicitly programmed to do the dump.  Could just do perf script
> and perf report?

I don't care.. actually `--debug perf-event-open` would work with
commands that call the syscall only.  But I'm fine either way.

>
> >
> >
> > I think we have 'perf report --mmap', no?
>
> Only shows user space maps.  Could add 'perf report --kmaps'?

That'd work too.  It's up to you.

Thanks,
Namhyung


>
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/perf-report.txt#n542 <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/perf-report.txt#n542>
> >
> > - Arnaldo
> >
> > Sent from smartphone
> >
> >
> >     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@intel.com <mailto:adrian.hunter@intel.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
> >     >
> >
>

  reply	other threads:[~2024-02-06  2:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 11:01 [PATCH 0/2] perf symbols: Slightly improve module file executable section mappings Adrian Hunter
2024-02-02 11:01 ` [PATCH 1/2] perf script: Make it possible to see perf's kernel and module memory mappings Adrian Hunter
2024-02-03  1:50   ` Namhyung Kim
     [not found]     ` <CA+JHD91GR=Jry_=Es4m+JnySjMoKrfajW40ZHq+eYFaF9Vsngg@mail.gmail.com>
2024-02-05  7:08       ` Adrian Hunter
2024-02-06  2:21         ` Namhyung Kim [this message]
2024-02-02 11:01 ` [PATCH 2/2] perf symbols: Slightly improve module file executable section mappings Adrian Hunter
2024-02-03  1:44   ` Namhyung Kim
2024-02-05  6:58     ` Adrian Hunter
2024-02-06  2:21       ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAM9d7chXSvhej4Evaq1gS_g-zPd0jOVBQDh3UmKAaE2UvP7-Hw@mail.gmail.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=like.xu.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).