26 Feb, 2010

4 commits

  • Introduce kprobes jump optimization arch-independent parts.
    Kprobes uses breakpoint instruction for interrupting execution
    flow, on some architectures, it can be replaced by a jump
    instruction and interruption emulation code. This gains kprobs'
    performance drastically.

    To enable this feature, set CONFIG_OPTPROBES=y (default y if the
    arch supports OPTPROBE).

    Changes in v9:
    - Fix a bug to optimize probe when enabling.
    - Check nearby probes can be optimize/unoptimize when disarming/arming
    kprobes, instead of registering/unregistering. This will help
    kprobe-tracer because most of probes on it are usually disabled.

    Changes in v6:
    - Cleanup coding style for readability.
    - Add comments around get/put_online_cpus().

    Changes in v5:
    - Use get_online_cpus()/put_online_cpus() for avoiding text_mutex
    deadlock.

    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    Cc: Ananth N Mavinakayanahalli
    Cc: Jim Keniston
    Cc: Srikar Dronamraju
    Cc: Christoph Hellwig
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: Anders Kaseorg
    Cc: Tim Abbott
    Cc: Andi Kleen
    Cc: Jason Baron
    Cc: Mathieu Desnoyers
    Cc: Frederic Weisbecker
    Cc: Ananth N Mavinakayanahalli
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • Make insn_slot framework support various size slots.
    Current insn_slot just supports one-size instruction buffer
    slot. However, kprobes jump optimization needs larger size
    buffers.

    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    Cc: Ananth N Mavinakayanahalli
    Cc: Jim Keniston
    Cc: Srikar Dronamraju
    Cc: Christoph Hellwig
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: Anders Kaseorg
    Cc: Tim Abbott
    Cc: Andi Kleen
    Cc: Jason Baron
    Cc: Mathieu Desnoyers
    Cc: Frederic Weisbecker
    Cc: Ananth N Mavinakayanahalli
    LKML-Reference:
    Signed-off-by: Ingo Molnar
    Cc: Ananth N Mavinakayanahalli
    Cc: Jim Keniston
    Cc: Srikar Dronamraju
    Cc: Christoph Hellwig
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: H. Peter Anvin
    Cc: Anders Kaseorg
    Cc: Tim Abbott
    Cc: Andi Kleen
    Cc: Jason Baron
    Cc: Mathieu Desnoyers

    Masami Hiramatsu
     
  • Change RELATIVEJUMP_INSTRUCTION macro to RELATIVEJUMP_OPCODE
    since it represents just the opcode byte.

    Signed-off-by: Masami Hiramatsu
    Acked-by: Mathieu Desnoyers
    Cc: systemtap
    Cc: DLE
    Cc: Ananth N Mavinakayanahalli
    Cc: Jim Keniston
    Cc: Srikar Dronamraju
    Cc: Christoph Hellwig
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: Anders Kaseorg
    Cc: Tim Abbott
    Cc: Andi Kleen
    Cc: Jason Baron
    Cc: Mathieu Desnoyers
    Cc: Frederic Weisbecker
    Cc: Ananth N Mavinakayanahalli
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • 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
     

25 Feb, 2010

8 commits

  • Be more clear about DSO long names and tell from which file
    kernel symbols were obtained, all in --verbose mode:

    [root@mica ~]# perf report -v > /dev/null
    Looking at the vmlinux_path (5 entries long)
    Using /lib/modules/2.6.33-rc8-tip-00777-g0918527-dirty/build/vmlinux for symbols
    [root@mica ~]# mv /lib/modules/2.6.33-rc8-tip-00777-g0918527-dirty/build/vmlinux /tmp/dd
    [root@mica ~]# perf report -v > /dev/null
    Looking at the vmlinux_path (5 entries long)
    Using /proc/kallsyms for symbols
    [root@mica ~]#

    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
     
  • To overcome a silly gcc warning:

    cc1: warnings being treated as errors
    builtin-top.c: In function ‘lookup_sym_source’:
    builtin-top.c:291: warning: not protecting local variables:
    variable length buffer make: *** [builtin-top.o] Error 1
    make: *** Waiting for unfinished jobs....

    That is emitted for this:

    const size_t pattern_len = BITS_PER_LONG / 4 + 2;
    char pattern[pattern_len + 1];

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Frédéric Weisbecker
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    LKML-Reference:
    [ -v2: macroify the naming style ]
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • In function dso__split_kallsyms(), curr_map saves the return value
    of map__new2. So check it instead of var map after the call returns.

    Signed-off-by: Zhang Yanmin
    Acked-by: David S. Miller
    Cc: # for .33.x
    Cc: Peter Zijlstra
    Cc: Mike Galbraith
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Zhang, Yanmin
     
  • syscall_name() helper, which resolves a syscall arch number to
    its name, is not yet available as we first need to implement
    event injection for it to work.

    Remove it from the documentation or tag its references as
    unavailable yet. Once it's implemented, we can just revert
    the current patch.

    Signed-off-by: Frederic Weisbecker
    Cc: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo

    Frederic Weisbecker
     
  • Also small update to perf-trace-perl and perf-trace docs.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     
  • If we know the size of a tuple in advance, there's no need to resize
    it - start out with the known size in the first place.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     
  • Adds a set of scripts that aggregate system call totals and system
    call errors. Most are Python scripts that also test basic
    functionality of the new Python engine, but there's also one Perl
    script added for comparison and for reference in some new
    Documentation contained in a later patch.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     
  • Add base support for Python scripting to perf trace.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     

24 Feb, 2010

5 commits

  • The check-perf-trace script only checks Perl functionality, and
    doesn't really need to be listed as as user script anyway.

    This only removes the '-report' shell script, so although it doesn't
    appear in the listing, the '-record' shell script and the check perf
    trace perl script itself is still available and can still be run
    manually as such:

    $ libexec/perf-core/scripts/perl/bin/check-perf-trace-record
    $ perf trace -s libexec/perf-core/scripts/perl/check-perf-trace.pl

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     
  • Create a scripting-engines directory to contain scripting engine
    implementation code, in anticipation of the addition of new scripting
    support. Also removes trace-event-perl.h.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     
  • This stuff is needed by all scripting engines; move it from the Perl
    engine source to a more common place.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     
  • Fix bogus calculation.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     
  • 'perf trace -s list' prints a list of the supported scripting
    languages. One problem with it is that it falls through and prints
    the trace as well. The use of 'list' for this also makes it easy to
    confuse with 'perf trace -l', used for listing available scripts. So
    change 'perf trace -s list' to 'perf trace -s lang' and fixes the
    fall-through problem.

    Signed-off-by: Tom Zanussi
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Keiichi KII
    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Arnaldo Carvalho de Melo
    LKML-Reference:
    Signed-off-by: Frederic Weisbecker

    Tom Zanussi
     

22 Feb, 2010

2 commits

  • As the parent comm then is worthless, confusing users about the
    thread where the sample really happened, leading to think that
    the sample happened in the parent, not where it really happened,
    in the children of a thread for which a PERF_RECORD_COMM event
    was not received.

    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
     
  • In 2161db9 we stopped failing when not finding modules when
    asked too, but then the kernel maps (just one, for vmlinux)
    wasn't having its ->end field correctly set up, so symbols were
    not being found for the vmlinux map because its range was 0-0.

    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
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     

08 Feb, 2010

4 commits

  • When 'perf record -g' a existing process, even with debuginfo
    packages, still cannnot get symbol from 'perf report'.

    try:

    perf record -g -p `pidof xxx` -f
    perf report

    68.26% :1181 b74870f2 [.] 0x000000b74870f2
    |
    |--32.09%-- 0xb73b5b44
    | 0xb7487102
    | 0xb748a4e2
    | 0xb748633d
    | 0xb73b41cd
    | 0xb73b4467
    | 0xb747d531

    The reason is: for existing process, in __cmd_record(),
    the pid is 0 rather than the existing process id.

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

    austin_zhang@linux.intel.com
     
  • Fixes these warnings:

    arch/x86/kernel/alternative.c: In function 'alternatives_text_reserved':
    arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
    arch/x86/kernel/alternative.c:402: warning: comparison of distinct pointer types lacks a cast
    arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast
    arch/x86/kernel/alternative.c:405: warning: comparison of distinct pointer types lacks a cast

    Caused by:

    2cfa197: ftrace/alternatives: Introducing *_text_reserved functions

    Changes in v2:
    - Use local variables to compare, instead of type casts.

    Reported-by: Ingo Molnar
    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • Because we may have aliases, like __GI___strcoll_l in
    /lib64/libc-2.10.2.so that appears in objdump as:

    $ objdump --start-address=0x0000003715a86420 \
    --stop-address=0x0000003715a872dc -dS /lib64/libc-2.10.2.so

    0000003715a86420 :
    3715a86420: 55 push %rbp
    3715a86421: 48 89 e5 mov %rsp,%rbp
    3715a86424: 41 57 push %r15
    [root@doppio linux-2.6-tip]#

    So look for the address exactly at the start of the line instead
    so that annotation can work for in these cases.

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

    Arnaldo Carvalho de Melo
     
  • First, for programs and prelinked libraries, annotate code was
    fooled by objdump output IPs (src->eip in the code) being
    wrongly converted to absolute IPs. In such case there were no
    conversion needed, but in

    src->eip = strtoull(src->line, NULL, 16);
    src->eip = map->unmap_ip(map, src->eip); // = eip + map->start - map->pgoff

    we were reading absolute address from objdump (e.g. 8048604) and
    then almost doubling it, because eip & map->start are
    approximately close for small programs.

    Needless to say, that later, in record_precise_ip() there was no
    matching with real runtime IPs.

    And second, like with `perf annotate` the problem with
    non-prelinked *.so was that we were doing rip -> objdump address
    conversion wrong.

    Also, because unlike `perf annotate`, `perf top` code does
    annotation based on absolute IPs for performance reasons(*), new
    helper for mapping objdump addresse to IP is introduced.

    (*) we get samples info in absolute IPs, and since we do lots of
    hit-testing on absolute IPs at runtime in record_precise_ip(), it's
    better to convert objdump addresses to IPs once and do no conversion
    at runtime.

    I also had to fix how objdump output is parsed (with hardcoded
    8/16 characters format, which was inappropriate for ET_DYN dsos
    with small addresses like '4ac')

    Also note, that not all objdump output lines has associtated
    IPs, e.g. look at source lines here:

    000004ac :
    extern "C"
    int my_strlen(const char *s)
    4ac: 55 push %ebp
    4ad: 89 e5 mov %esp,%ebp
    4af: 83 ec 10 sub $0x10,%esp
    {
    int len = 0;
    4b2: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp)
    4b9: eb 08 jmp 4c3

    while (*s) {
    ++len;
    4bb: 83 45 fc 01 addl $0x1,-0x4(%ebp)
    ++s;
    4bf: 83 45 08 01 addl $0x1,0x8(%ebp)

    So we mark them with eip=0, and ignore such lines in annotate
    lookup code.

    Signed-off-by: Kirill Smelkov
    [ Note: one hunk of this patch was applied by Mike in 57d8188 ]
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Kirill Smelkov
     

05 Feb, 2010

1 commit

  • Since mcount function can be called from everywhere,
    it should be blacklisted. Moreover, the "mcount" symbol
    is a special symbol name. So, it is better to put it in
    the generic blacklist.

    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    Cc: Ananth N Mavinakayanahalli
    Cc: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

04 Feb, 2010

16 commits

  • perf top and perf record refuses to initialize on non-modular kernels:
    refuse to initialize:

    $ perf top -v
    map_groups__set_modules_path_dir: cannot open /lib/modules/2.6.33-rc6-tip-00586-g398dde3-dirty/

    Cc: 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

    Ingo Molnar
     
  • Setting _FILE_OFFSET_BITS and using O_LARGEFILE, lseek64, etc,
    is redundant. Thanks H. Peter Anvin for pointing it out.

    So, this patch removes O_LARGEFILE, lseek64, etc.

    Suggested-by: "H. Peter Anvin"
    Signed-off-by: Xiao Guangrong
    Cc: Frederic Weisbecker
    Cc: Steven Rostedt
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Xiao Guangrong
     
  • We cannot assume that because hwc->idx == assign[i], we can avoid
    reprogramming the counter in hw_perf_enable().

    The event may have been scheduled out and another event may have been
    programmed into this counter. Thus, we need a more robust way of
    verifying if the counter still contains config/data related to an event.

    This patch adds a generation number to each counter on each cpu. Using
    this mechanism we can verify reliabilty whether the content of a counter
    corresponds to an event.

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

    Stephane Eranian
     
  • Avoid accidental misuse by failing to compile things

    Suggested-by: Andrew Morton
    Signed-off-by: Peter Zijlstra
    Cc: Linus Torvalds
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Implement Intel Core Solo/Duo, aka.
    Intel Architectural Performance Monitoring Version 1.

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

    Peter Zijlstra
     
  • Pretty much all of the calls do perf_disable/perf_enable cycles, pull
    that out to cut back on hardware programming.

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

    Peter Zijlstra
     
  • Remove record freezing. Because kprobes never puts probe on
    ftrace's mcount call anymore, it doesn't need ftrace to check
    whether kprobes on it.

    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    Cc: Steven Rostedt
    Cc: przemyslaw@pawelczyk.it
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • Check whether the address of new probe is already reserved by
    ftrace or alternatives (on x86) when registering new probe.
    If reserved, it returns an error and not register the probe.

    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    Cc: Steven Rostedt
    Cc: przemyslaw@pawelczyk.it
    Cc: Frederic Weisbecker
    Cc: Ananth N Mavinakayanahalli
    Cc: Jim Keniston
    Cc: Mathieu Desnoyers
    Cc: Jason Baron
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • Introducing *_text_reserved functions for checking the text
    address range is partially reserved or not. This patch provides
    checking routines for x86 smp alternatives and dynamic ftrace.
    Since both functions modify fixed pieces of kernel text, they
    should reserve and protect those from other dynamic text
    modifier, like kprobes.

    This will also be extended when introducing other subsystems
    which modify fixed pieces of kernel text. Dynamic text modifiers
    should avoid those.

    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    Cc: Steven Rostedt
    Cc: przemyslaw@pawelczyk.it
    Cc: Frederic Weisbecker
    Cc: Ananth N Mavinakayanahalli
    Cc: Jim Keniston
    Cc: Mathieu Desnoyers
    Cc: Jason Baron
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • Disable kprobe booster when CONFIG_PREEMPT=y at this time,
    because it can't ensure that all kernel threads preempted on
    kprobe's boosted slot run out from the slot even using
    freeze_processes().

    The booster on preemptive kernel will be resumed if
    synchronize_tasks() or something like that is introduced.

    Signed-off-by: Masami Hiramatsu
    Cc: systemtap
    Cc: DLE
    Cc: Ananth N Mavinakayanahalli
    Cc: Frederic Weisbecker
    Cc: Jim Keniston
    Cc: Mathieu Desnoyers
    Cc: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     
  • Signed-off-by: Mike Galbraith
    Cc: Kirill Smelkov
    Cc: Arnaldo Carvalho de Melo
    Cc: Arnaldo Carvalho de Melo
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Mike Galbraith
     
  • By relying on logic in dso__load_kernel_sym(), we can
    automatically load vmlinux.

    The only thing which needs to be adjusted, is how --sym-annotate
    option is handled - now we can't rely on vmlinux been loaded
    until full successful pass of dso__load_vmlinux(), but that's
    not the case if we'll do sym_filter_entry setup in
    symbol_filter().

    So move this step right after event__process_sample() where we
    know the whole dso__load_kernel_sym() pass is done.

    By the way, though conceptually similar `perf top` still can't
    annotate userspace - see next patches with fixes.

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

    Kirill Smelkov
     
  • 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
     
  • We want to stream events as fast as possible to perf.data, and
    also in the future we want to have splice working, when no
    interception will be possible.

    Using build_id__mark_dso_hit_ops to create the list of DSOs that
    back MMAPs we also optimize disk usage in the build-id cache by
    only caching DSOs that had hits.

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

    Arnaldo Carvalho de Melo
     
  • Because 'perf record' will have to find the build-ids in after
    we stop recording, so as to reduce even more the impact in the
    workload while we do the measurement.

    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