16 Mar, 2010

1 commit

  • Before this patch we would not find a vmlinux, then try to pass
    objdump "[kernel.kallsyms]" as the filename, it would get
    confused and produce no output:

    [root@doppio ~]# perf annotate n_tty_write

    ------------------------------------------------
    Percent | Source code & Disassembly of [kernel.kallsyms]
    ------------------------------------------------

    Now we check that and emit meaningful warning:

    [root@doppio ~]# perf annotate n_tty_write
    Can't annotate n_tty_write: No vmlinux file was found in the
    path: [0] vmlinux
    [1] /boot/vmlinux
    [2] /boot/vmlinux-2.6.34-rc1-tip+
    [3] /lib/modules/2.6.34-rc1-tip+/build/vmlinux
    [4] /usr/lib/debug/lib/modules/2.6.34-rc1-tip+/vmlinux
    [root@doppio ~]#

    This bug was introduced when we added automatic search for
    vmlinux, before that time the user had to specify a vmlinux
    file.

    v2: Print the warning just for the first symbol found when no
    symbol name is specified, otherwise it will spam the screen
    repeating the warning for each symbol.

    Reported-by: Ingo Molnar
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc:
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

10 Mar, 2010

2 commits

  • Now that report can store historgrams for multiple events we
    need to be able to do the post processing work for each
    histogram. This patch changes the post processing functions so
    that they can be called individually for each event's histogram.

    Signed-off-by: Eric B Munson
    [ Guarantee bisectabilty by fixing up builtin-report.c ]
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Eric B Munson
     
  • In order to minimize the impact of storing multiple events in a
    report this function will now take the root of the histogram
    tree so that the logic for selecting the proper tree can be
    inserted before the call.

    Signed-off-by: Eric B Munson
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Eric B Munson
     

26 Feb, 2010

2 commits

  • Without this patch we get this for need_resched:

    [root@mica ~]# perf annotate need_resched

    ------------------------------------------------
    Percent | Source code & Disassembly of vmlinux
    ------------------------------------------------
    :
    :
    : Disassembly of section .text:
    :
    : ffffffff810095ed :
    : return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
    : }
    :
    : static inline int need_resched(void)
    : {
    0.00 : ffffffff810095ed: 55 push %rbp
    : return unlikely(test_thread_flag(TIF_NEED_RESCHED));
    0.00 : ffffffff810095ee: be 03 00 00 00 mov $0x3,%esi
    :
    : static inline struct thread_info *current_thread_info(void)
    : {
    : struct thread_info *ti;
    : ti = (void *)(percpu_read_stable(kernel_stack) +
    0.00 : ffffffff810095f3: 65 48 8b 3c 25 48 b5 mov %gs:0xb548,%rdi
    0.00 : ffffffff810095fa: 00 00
    : return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
    : }
    :
    : static inline int need_resched(void)
    : {
    0.00 : ffffffff810095fc: 48 89 e5 mov %rsp,%rbp
    : return unlikely(test_thread_flag(TIF_NEED_RESCHED));
    0.00 : ffffffff810095ff: 48 81 ef d8 1f 00 00 sub $0x1fd8,%rdi
    0.00 : ffffffff81009606: e8 9d ff ff ff callq ffffffff810095a8
    : }
    0.00 : ffffffff8100960b: c9 leaveq
    0.00 : ffffffff8100960c: 85 c0 test %eax,%eax
    0.00 : ffffffff8100960e: 0f 95 c0 setne %al
    0.00 : ffffffff81009611: 0f b6 c0 movzbl %al,%eax
    : Disassembly of section .vsyscall_0:
    : Disassembly of section .vsyscall_fn:
    : Disassembly of section .vsyscall_1:
    : Disassembly of section .vsyscall_2:
    : Disassembly of section .init.text:
    : Disassembly of section .altinstr_replacement:
    : Disassembly of section .exit.text:
    [root@mica ~]#

    But from the 'perf report' result we know that there are hits
    for need_resched on a 4 way machine mostly doing nothing, so
    after adding code to show what is in each hist offset and
    collapsing IP hits for what happens between objdump lines we
    get, for the same perf.data file:

    [root@mica ~]# perf annotate -v need_resched

    ------------------------------------------------
    Percent | Source code & Disassembly of vmlinux
    ------------------------------------------------
    :
    :
    : Disassembly of section .text:
    :
    : ffffffff810095ed :
    : return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
    : }
    :
    : static inline int need_resched(void)
    : {
    0.00 : ffffffff810095ed: 55 push %rbp
    : return unlikely(test_thread_flag(TIF_NEED_RESCHED));
    52.78 : ffffffff810095ee: be 03 00 00 00 mov $0x3,%esi
    :
    : static inline struct thread_info *current_thread_info(void)
    : {
    : struct thread_info *ti;
    : ti = (void *)(percpu_read_stable(kernel_stack) +
    0.00 : ffffffff810095f3: 65 48 8b 3c 25 48 b5 mov %gs:0xb548,%rdi
    0.00 : ffffffff810095fa: 00 00
    : return (state & TASK_INTERRUPTIBLE) || __fatal_signal_pending(p);
    : }
    :
    : static inline int need_resched(void)
    : {
    0.00 : ffffffff810095fc: 48 89 e5 mov %rsp,%rbp
    : return unlikely(test_thread_flag(TIF_NEED_RESCHED));
    9.72 : ffffffff810095ff: 48 81 ef d8 1f 00 00 sub $0x1fd8,%rdi
    0.00 : ffffffff81009606: e8 9d ff ff ff callq ffffffff810095a8
    : }
    0.00 : ffffffff8100960b: c9 leaveq
    0.00 : ffffffff8100960c: 85 c0 test %eax,%eax
    37.50 : ffffffff8100960e: 0f 95 c0 setne %al
    0.00 : ffffffff81009611: 0f b6 c0 movzbl %al,%eax
    : Disassembly of section .vsyscall_0:
    : Disassembly of section .vsyscall_fn:
    : Disassembly of section .vsyscall_1:
    : Disassembly of section .vsyscall_2:
    : Disassembly of section .init.text:
    : Disassembly of section .altinstr_replacement:
    : Disassembly of section .exit.text:
    [root@mica ~]#

    And now 'perf annotate -v', verbose mode, will show the hits per
    precise IP, so that one can make sense of the attribution to
    each objdumop line:

    [root@mica ~]# perf annotate -v need_resched
    Looking at the vmlinux_path (5 entries long)
    Using /lib/modules/2.6.33-rc8-tip-00784-g3471df5-dirty/build/vmlinux
    for symbols annotate_sym: filename=/lib/modules/2.6.33-rc8-tip-00784-g3471df5-dirty/build/vmlinux, sym=need_resched, start=0xffffffff810095ed, end=0xffffffff81009614

    ------------------------------------------------
    Percent | Source code & Disassembly of vmlinux
    ------------------------------------------------
    ffffffff810095f1: 152
    ffffffff81009603: 28
    ffffffff8100960f: 55
    ffffffff81009610: 53
    h->sum: 288

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: David Miller
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • Because symbol->end is not fixed up at symbol_filter time, only
    after all symbols for a DSO are loaded, and that, for asm
    symbols, may be bogus, causing segfaults when hits happen in
    these symbols.

    Reported-by: David Miller
    Reported-by: Anton Blanchard
    Acked-by: David Miller
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: # for .33.x. Does not apply cleanly, needs backport.
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

04 Feb, 2010

2 commits

  • The problem was we were incorrectly calculating objdump
    addresses for sym->start and sym->end, look:

    For simple ET_DYN type DSO (*.so) with one function, objdump -dS
    output is something like this:

    000004ac :
    int my_strlen(const char *s)
    4ac: 55 push %ebp
    4ad: 89 e5 mov %esp,%ebp
    4af: 83 ec 10 sub $0x10,%esp
    {

    i.e. we have relative-to-dso-mapping IPs (=RIP) there.

    For ET_EXEC type and probably for prelinked libs as well (sorry
    can't test - I don't use prelink) objdump outputs absolute IPs,
    e.g.

    08048604 :
    extern "C"
    int zz_strlen(const char *s)
    8048604: 55 push %ebp
    8048605: 89 e5 mov %esp,%ebp
    8048607: 83 ec 10 sub $0x10,%esp
    {

    So, if sym->start is always relative to dso mapping(*), we'll
    have to unmap it for ET_EXEC like cases, and leave as is for
    ET_DYN cases.

    (*) and it is - we've explicitely made it relative. Look for
    adjust_symbols handling in dso__load_sym()

    Previously we were always unmapping sym->start and for ET_DYN
    dsos resulting addresses were wrong, and so objdump output was
    empty.

    The end result was that perf annotate output for symbols from
    non-prelinked *.so had always 0.00% percents only, which is
    wrong.

    To fix it, let's introduce a helper for converting rip to
    objdump address, and also let's document what map_ip() and
    unmap_ip() do -- I had to study sources for several hours to
    understand it.

    Signed-off-by: Kirill Smelkov
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Kirill Smelkov
     
  • Not to pollute too much 'perf annotate' debugging sessions.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

16 Jan, 2010

1 commit

  • Since they can come from another architecture with bigger
    pointers, i.e. processing a 64-bit perf.data on a 32-bit arch.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

28 Dec, 2009

1 commit


16 Dec, 2009

3 commits

  • So that --dsos, --comm, --symbols can bem used in more tools,
    like in perf diff:

    $ perf record -f find / > /dev/null
    $ perf record -f find / > /dev/null
    $ perf diff --dsos /lib64/libc-2.10.1.so | head -5
    1 +22392124 /lib64/libc-2.10.1.so _IO_vfprintf_internal
    2 +6410655 /lib64/libc-2.10.1.so __GI_memmove
    3 +1 +9192692 /lib64/libc-2.10.1.so _int_malloc
    4 -1 -15158605 /lib64/libc-2.10.1.so _int_free
    5 +45669 /lib64/libc-2.10.1.so _IO_new_file_xsputn
    $

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • Will be used in perf diff too.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • This simplifies a lot of functions, less stuff to be done by
    tool writers.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

15 Dec, 2009

2 commits


14 Dec, 2009

8 commits


12 Dec, 2009

1 commit

  • That does all the initialization boilerplate, opening the file,
    reading the header, checking if it is valid, etc.

    And that will as well have the threads list, kmap (now) global
    variable, etc, so that we can handle two (or more) perf.data files
    describing sessions to compare.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

01 Dec, 2009

1 commit

  • perf-annotate doesn't parse perf.data correctly in that it
    doesn't read perf header. Fix this by using
    mmap_dispatch_perf_file().

    Before:

    TOTAL events: 17565
    MMAP events: 3221
    LOST events: 10
    COMM events: 235
    EXIT events: 2
    THROTTLE events: 1
    UNTHROTTLE events: 2
    FORK events: 10
    READ events: 1
    SAMPLE events: 14083

    After:

    TOTAL events: 17290
    MMAP events: 3203
    LOST events: 0
    COMM events: 234
    EXIT events: 1
    THROTTLE events: 0
    UNTHROTTLE events: 0
    FORK events: 0
    READ events: 0
    SAMPLE events: 13852

    Signed-off-by: Li Zefan
    Cc: Frederic Weisbecker
    Cc: Arnaldo Carvalho de Melo
    Cc: Peter Zijlstra
    Cc: Arjan van de Ven
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Li Zefan
     

28 Nov, 2009

6 commits

  • Now we have a very high level routine for simple tools to
    process IP sample events:

    int event__preprocess_sample(const event_t *self,
    struct addr_location *al,
    symbol_filter_t filter)

    It receives the event itself and will insert new threads in the
    global threads list and resolve the map and symbol, filling all
    this info into the new addr_location struct, so that tools like
    annotate and report can further process the event by creating
    hist_entries in their specific way (with or without callgraphs,
    etc).

    It in turn uses the new next layer function:

    void thread__find_addr_location(struct thread *self, u8 cpumode,
    enum map_type type, u64 addr,
    struct addr_location *al,
    symbol_filter_t filter)

    This one will, given a thread (userspace or the kernel kthread
    one), will find the given type (MAP__FUNCTION now, MAP__VARIABLE
    too in the near future) at the given cpumode, taking vdsos into
    account (userspace hit, but kernel symbol) and will fill all
    these details in the addr_location given.

    Tools that need a more compact API for plain function
    resolution, like 'kmem', can use this other one:

    struct symbol *thread__find_function(struct thread *self, u64 addr,
    symbol_filter_t filter)

    So, to resolve a kernel symbol, that is all the 'kmem' tool
    needs, its just a matter of calling:

    sym = thread__find_function(kthread, addr, NULL);

    The 'filter' parameter is needed because we do lazy
    parsing/loading of ELF symtabs or /proc/kallsyms.

    With this we remove more code duplication all around, which is
    always good, huh? :-)

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: John Kacur
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • While implementing event__preprocess_sample, that will do all of
    the symbol lookup in one convenient function, I noticed that
    util/process_event.[ch] were not being used at all, then started
    looking if there were other functions that could be shared
    and...

    All those functions really don't need to receive offset + head,
    the only thing they did was common to all of them, so do it at
    one place instead.

    Stats about number of each type of event processed now is done
    in a central place.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: John Kacur
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • Making the routines that were so far specific to the kernel maps
    useful for all threads.

    This is done by making the kernel maps be contained in a kernel
    "thread".

    This gets the kernel specific routines closer to the userspace
    counterparts, which will help in reducing the boilerplate for
    resolving a symbol, as will be demonstrated in the next patches.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • By using an array of rb_roots in struct dso we can, from a
    struct map instance to get the right symbol rb_tree more easily.
    This way we can have just one symbol lookup method for struct
    map instances, map__find_symbol, instead of one per symtab type
    (functions, variables).

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • perf annotate was the only user, and it doesn't really need it.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • As we'll have kernel_map[s]__variables too.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

24 Nov, 2009

4 commits

  • Paving the way for supporting variable in adition to function
    symbols.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • And also express its configuration toggles via a struct.

    Now all one has to do is to call symbol__init(NULL) if the
    defaults are OK, or pass a struct symbol_conf pointer with the
    desired configuration.

    If a tool uses kernel_maps__find_symbol() to look at the kernel
    and modules mappings for a symbol but didn't call symbol__init()
    first, that will generate a one time warning too, alerting the
    subcommand developer that symbol__init() must be called.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • Prevent bit-rot in perf-annotate by using common functions where
    possible. Here we create process_events.[ch] to hold the common
    functions.

    Signed-off-by: John Kacur
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: acme@redhat.com
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    John Kacur
     
  • Now that we can check the buildid to see if it really matches,
    this can be done safely:

    vmlinux
    /boot/vmlinux
    /boot/vmlinux-
    /lib/modules//build/vmlinux
    /usr/lib/debug/lib/modules/%s/vmlinux

    More can be added - if you know about distros that put the
    vmlinux somewhere else please let us know.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

21 Nov, 2009

2 commits

  • Just like we do with the other DSOs. This also simplifies the
    kernel_maps setup process, now all that the tools need to do is
    to call kernel_maps__init and the maps for the modules and
    kernel will be created, then, later, when
    kernel_maps__find_symbol() is used, it will also call
    maps__find_symbol that already checks if the symtab was loaded,
    loading it if needed.

    Now if one does 'perf top --hide_kernel_symbols' we won't pay
    the price of loading the (many) symbols in /proc/kallsyms or
    vmlinux.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • It should just load kernel symbols, not load the list of
    modules. There are more stuff to move to other routines, but
    lets do it in several steps.

    End goal is to be able to defer symbol table loading till we
    find a hit for that map address range. So that the kernel &
    modules are handled just like all the other DSOs in the system.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

02 Nov, 2009

1 commit

  • Before we were storing this in the DSO, but in fact this is a
    property of the 'symbol' class, not something that will vary
    among DSOs, so move it to a global variable and initialize it
    using the existing symbol__init routine.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

29 Oct, 2009

1 commit


23 Oct, 2009

1 commit

  • We were using eprintf in some places, that looks at a global
    'verbose' level, and at other places passing a 'v' parameter to
    specify the verbosity level, unify it by introducing
    pr_{err,warning,debug,etc}, just like in the kernel.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

21 Oct, 2009

1 commit

  • If the user doesn't pass a symbol name to annotate, it will
    annotate all the symbols that have hits, in order, just like
    'perf report -s comm,dso,symbol'.

    This is a natural followup patch to the one that uses
    output_hists to find the symbols with hits.

    The common case is to annotate the first few entries at the top
    of a perf report, so lets type less characters.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo