[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20170107105002.932daef61b160fd09a854b66@kernel.org>
Date: Sat, 7 Jan 2017 10:50:02 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Namhyung Kim <namhyung@...nel.org>
Subject: Re: [PATCH perf/core 3/3] perf-probe: Fix to probe on gcc generated
functions in modules
On Fri, 6 Jan 2017 15:17:11 -0300
Arnaldo Carvalho de Melo <acme@...nel.org> wrote:
> Em Sat, Jan 07, 2017 at 01:22:23AM +0900, Masami Hiramatsu escreveu:
> > On Thu, 5 Jan 2017 15:47:43 -0300
> > Arnaldo Carvalho de Melo <acme@...nel.org> wrote:
> > > Em Thu, Jan 05, 2017 at 12:30:37PM -0300, Arnaldo Carvalho de Melo escreveu:
> > > > Em Thu, Jan 05, 2017 at 08:20:19PM +0900, Masami Hiramatsu escreveu:
> > > > > On Wed, 4 Jan 2017 11:48:56 -0300
> > > > > Arnaldo Carvalho de Melo <acme@...nel.org> wrote:
> > > > > > [acme@...et linux]$ grep e1000_xmit_frame /proc/kallsyms
> > > > > > ffffffffc046fc10 t e1000_xmit_frame [e1000e]
> > > > > > [acme@...et linux]$
> > >
> > > > > OK, it sounds reasonable to me too. BTW, how can I get the map for kallsyms?
> > > > > May machine__findnew_module_map(host_machine, ,"[kernel.kallsyms]")
> > > > > include module symbols too?
> > >
> > > > Probably what you want is:
> > >
> > > > symbol = machine__find_kernel_function_by_name(machine, name, &map);
> > >
> > > > Then, if symbol is not NULL, map->dso->name will have your module name,
> > > > map->dso->long_name will have the .ko path, etc.
> > >
> > > Take a look at 'perf kallsyms' a simple toy cmd that exercises the APIs
> > > you need:
> > >
> > > https://git.kernel.org/cgit/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=25c92235676d2655e3f31ffe02bd4355d838e5e9
> > >
> > > Basically:
> > >
> > > struct machine *machine = machine__new_kallsyms();
> > > struct map *map;
> > > struct symbol *symbol = machine__find_kernel_function_by_name(machine, symbol_name, &map);
> > >
> > > Then you have symbol->{addr,end,name,etc} and map->dso->{long,short}_name
> > >
> > > $ perf kallsyms e1000_xmit_frame usb_stor_set_xfer_buf
> > > e1000_xmit_frame: [e1000e] /lib/modules/4.9.0+/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko 0xffffffffc046fc10-0xffffffffc0470bb0 (0x19c80-0x1ac20)
> > > usb_stor_set_xfer_buf: [usb_storage] /lib/modules/4.9.0+/kernel/drivers/usb/storage/usb-storage.ko 0xffffffffc057aea0-0xffffffffc057af19 (0xf10-0xf89)
> >
> > I've found an issue on perf kallsyms. Please see below.
> >
> > When I run kallsyms without root privilege, it works well.
> >
> > $ ./perf kallsyms -vv drm_malloc_ab
> > Failed to open /proc/kcore. Note /proc/kcore requires CAP_SYS_RAWIO capability to access.
> > drm_malloc_ab: [i915] /lib/modules/4.8.15-300.fc25.x86_64/kernel/drivers/gpu/drm/i915/i915.ko.xz 0xffffffffc0211950-0xffffffffc02119a6 (0x309c0-0x30a16)
> >
> > However, with root privilege it failed to get correct module name...
> >
> > $ sudo ./perf kallsyms -vv drm_malloc_ab
> > Using /proc/kcore for kernel object code
> > drm_malloc_ab: [kernel] /proc/kcore 0xffffffffc0211950-0xffffffffc02119b0 (0x7fffc0214950-0x7fffc02149b0)
>
> Right, that is something that needs fixing, please try with the patch
> below.
>
> The problem is that when using /proc/kcore it messes up the creation of
> one map per module :-\
OK, it works now :)
$ sudo ./perf kallsyms drm_malloc_ab
drm_malloc_ab: [i915] /lib/modules/4.8.15-300.fc25.x86_64/kernel/drivers/gpu/drm/i915/i915.ko.xz 0xffffffffc0188950-0xffffffffc01889a6 (0x309c0-0x30a16)
Tested-by: Masami Hiramatsu <mhiramat@...nel.org>
Thanks!
>
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 4aef30ec8bc3..43d533b075df 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -91,7 +91,7 @@ struct machine *machine__new_kallsyms(void)
> {
> struct machine *machine = machine__new_host();
>
> - if (machine && machine__load_kallsyms(machine, "/proc/kallsyms", MAP__FUNCTION) <= 0) {
> + if (machine && __machine__load_kallsyms(machine, "/proc/kallsyms", MAP__FUNCTION, true) <= 0) {
> machine__delete(machine);
> machine = NULL;
> }
--
Masami Hiramatsu <mhiramat@...nel.org>
Powered by blists - more mailing lists