Re: how to use perf annotate on the kernel

From: Stephane Eranian
Date: Fri Jun 04 2010 - 04:55:31 EST


Hi,

This patch seems to work now.
Thanks.

On Fri, Jun 4, 2010 at 2:39 AM, Arnaldo Carvalho de Melo
<acme@xxxxxxxxxxxxx> wrote:
> Em Thu, Jun 03, 2010 at 09:20:39PM -0300, Arnaldo Carvalho de Melo escreveu:
>> Em Thu, Jun 03, 2010 at 08:18:04PM +0200, Stephane Eranian escreveu:
>> > perf annotate __lock_acquire -k /home/eranian/perfmon/official/tip/build/vmlinux
>> > build id event received for [kernel.kallsyms]:
>> > 5c110a704293a259fbe11158dc1b25107ad7a23e
>> > build id event received for
>> > /lib/modules/2.6.35-rc1-tip/kernel/arch/x86/kernel/cpu/cpufreq/mperf.ko:
>> > cb5
>> > build id event received for
>> > /lib/modules/2.6.35-rc1-tip/kernel/drivers/cpufreq/cpufreq_ondemand.ko:
>> > cdb5
>> > Using /home/eranian/perfmon/official/tip/build/vmlinux for symbols
>> > hist_entry__inc_addr_samples: ip=0xffffffff81073b36
>> > 0xffffffff81073b30 __lock_acquire: period++ [ip: 0xffffffff81073b36, 0x6] => 1
>> > hist_entry__inc_addr_samples: ip=0xffffffff81073c94
>> >
>> > But in the end I get:
>> > objdump: '[kernel.kallsyms]': No such file
>>
>> Reproduced, working on it now. I've been testing only with vmlinux in
>> the path it searches for, not by directly specifying it, will get that
>> fixed, thanks,
>
> Should be fixed by this patch:
>
> [root@emilia ~]# perf annotate -k /lib/modules/2.6.35-rc1/build/vmlinux.OFF n_tty_write | head -50
>
>
> ------------------------------------------------
> ÂPercent | Â Â ÂSource code & Disassembly of vmlinux.OFF
> ------------------------------------------------
> Â Â Â Â :
> Â Â Â Â :
> Â Â Â Â :
> Â Â Â Â : Â Â ÂDisassembly of section .text:
> Â Â Â Â :
> Â Â Â Â : Â Â Âffffffff81288820 <n_tty_write>:
> Â Â Â Â : Â Â Â * Â Â Â Â Â Â Â Âlock themselves)
> Â Â Â Â : Â Â Â */
> Â Â Â Â :
> Â Â Â Â : Â Â Âstatic ssize_t n_tty_write(struct tty_struct *tty, struct file *file,
> Â Â Â Â : Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â const unsigned char *buf, size_t nr)
> Â Â Â Â : Â Â Â{
>  Â0.00 :   Âffffffff81288820:    41 57          push  %r15
> Â Â Â Â :
> Â Â Â Â : Â Â ÂDECLARE_PER_CPU(struct task_struct *, current_task);
> Â Â Â Â :
> Â Â Â Â : Â Â Âstatic __always_inline struct task_struct *get_current(void)
> Â Â Â Â : Â Â Â{
> Â Â Â Â : Â Â Â Â Â Â Âreturn percpu_read_stable(current_task);
>  Â0.00 :   Âffffffff81288822:    65 48 8b 04 25 40 cc  Âmov  Â%gs:0xcc40,%rax
> Â Â0.00 : Â Â Âffffffff81288829: Â Â Â 00 00
>  Â0.00 :   Âffffffff8128882b:    41 56          push  %r14
>  Â0.00 :   Âffffffff8128882d:    41 55          push  %r13
>  Â0.00 :   Âffffffff8128882f:    49 89 cd        Âmov  Â%rcx,%r13
>  Â0.00 :   Âffffffff81288832:    41 54          push  %r12
>  Â0.00 :   Âffffffff81288834:    49 89 d4        Âmov  Â%rdx,%r12
>  Â0.00 :   Âffffffff81288837:    55           Âpush  %rbp
>  Â0.00 :   Âffffffff81288838:    48 89 f5        Âmov  Â%rsi,%rbp
>  Â0.00 :   Âffffffff8128883b:    53           Âpush  %rbx
>  Â0.00 :   Âffffffff8128883c:    48 89 fb        Âmov  Â%rdi,%rbx
>  Â0.00 :   Âffffffff8128883f:    48 83 ec 58       sub  Â$0x58,%rsp
> Â Â Â Â : Â Â Â Â Â Â Âconst unsigned char *b = buf;
> Â Â Â Â : Â Â Â Â Â Â ÂDECLARE_WAITQUEUE(wait, current);
>  Â0.00 :   Âffffffff81288843:    48 c7 44 24 20 00 00  Âmovq  $0x0,0x20(%rsp)
> Â Â0.00 : Â Â Âffffffff8128884a: Â Â Â 00 00
>  Â7.14 :   Âffffffff8128884c:    48 c7 44 24 38 00 00  Âmovq  $0x0,0x38(%rsp)
> Â Â0.00 : Â Â Âffffffff81288853: Â Â Â 00 00
>  Â0.00 :   Âffffffff81288855:    48 c7 44 24 40 00 00  Âmovq  $0x0,0x40(%rsp)
> Â Â0.00 : Â Â Âffffffff8128885c: Â Â Â 00 00
>  Â7.14 :   Âffffffff8128885e:    48 89 44 24 28     Âmov  Â%rax,0x28(%rsp)
>  Â0.00 :   Âffffffff81288863:    48 c7 44 24 30 30 49  Âmovq  $0xffffffff81044930,0x30(%rsp)
> Â Â0.00 : Â Â Âffffffff8128886a: Â Â Â 04 81
> Â Â Â Â : Â Â Â Â Â Â Âint c;
> Â Â Â Â : Â Â Â Â Â Â Âssize_t retval = 0;
> Â Â Â Â :
> [root@emilia ~]#
>
> From 842b66de6807e72bddfd24a63742bacd0f853872 Mon Sep 17 00:00:00 2001
> From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Date: Thu, 3 Jun 2010 18:35:55 -0300
> Subject: [PATCH 1/1] perf symbols: Set the DSO long name when using symbol_conf.vmlinux_name
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> We need to set the long name to the name specified via, for instance,
> 'perf annotate --vmlinux /path/to/vmlinux', if not it will remain as
> '[kernel.kallsyms]' and that will make annotate fail when passing this
> as the vmlinux name in the call to objdump.
>
> The way this is setup grew unwieldly and dso__load_vmlinux is the
> function that should allocate space for the long name, with callers not
> assuming that filenames should be allocated somehow by then (strdup,
> dso__build_id_filename, etc).
>
> For now this is the minimalistic patch, a proper fix for .36 will be
> made.
>
> Reported-by: Stephane Eranian <eranian@xxxxxxxxxx>
> Cc: David S. Miller <davem@xxxxxxxxxxxxx>
> Cc: FrÃdÃric Weisbecker <fweisbec@xxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxx>
> Cc: Mike Galbraith <efault@xxxxxx>
> Cc: Paul Mackerras <paulus@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Stephane Eranian <eranian@xxxxxxxxxx>
> Cc: Tom Zanussi <tzanussi@xxxxxxxxx>
> LKML-Reference: <new-submission>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> ---
> Âtools/perf/util/symbol.c | Â Â8 ++++++--
> Â1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 7fd6b15..b63e571 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -1745,7 +1745,12 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
> Â Â Â Âif (symbol_conf.vmlinux_name != NULL) {
> Â Â Â Â Â Â Â Âerr = dso__load_vmlinux(self, map,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âsymbol_conf.vmlinux_name, filter);
> - Â Â Â Â Â Â Â goto out_try_fixup;
> + Â Â Â Â Â Â Â if (err > 0) {
> + Â Â Â Â Â Â Â Â Â Â Â dso__set_long_name(self,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstrdup(symbol_conf.vmlinux_name));
> + Â Â Â Â Â Â Â Â Â Â Â goto out_fixup;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â return err;
> Â Â Â Â}
>
> Â Â Â Âif (vmlinux_path != NULL) {
> @@ -1806,7 +1811,6 @@ do_kallsyms:
> Â Â Â Â Â Â Â Âpr_debug("Using %s for symbols\n", kallsyms_filename);
> Â Â Â Âfree(kallsyms_allocated_filename);
>
> -out_try_fixup:
> Â Â Â Âif (err > 0) {
> Âout_fixup:
> Â Â Â Â Â Â Â Âif (kallsyms_filename != NULL)
> --
> 1.6.5.2
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/