1. 23 Sep, 2011 10 commits
    • Stephane Eranian's avatar
      perf symbols: Fix issue with binaries using 16-bytes buildids (v2) · be96ea8f
      Stephane Eranian authored
      Buildid can vary in size. According to the man page of ld, buildid can
      be 160 bits (sha1) or 128 bits (md5, uuid). Perf assumes buildid size of
      20 bytes (160 bits) regardless. When dealing with md5 buildids, it would
      thus read more than needed and that would cause mismatches and samples
      without symbols.
      
      This patch fixes this by taking into account the actual buildid size as
      encoded int he section header. The leftover bytes are also cleared.
      
      This second version fixes a minor issue with the memset() base position.
      
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Robert Richter <robert.richter@amd.com>
      Cc: Stephane Eranian <eranian@gmail.com>
      Link: http://lkml.kernel.org/r/4cc1af3c.8ee7d80a.5a28.ffff868e@mx.google.comSigned-off-by: default avatarStephane Eranian <eranian@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      be96ea8f
    • David Ahern's avatar
      perf tool: Fix endianness handling of u32 data in samples · 936be503
      David Ahern authored
      Currently, analyzing PPC data files on x86 the cpu field is always 0 and
      the tid and pid are backwards. For example, analyzing a PPC file on PPC
      the pid/tid fields show:
      
              rsyslogd  1210/1212
      
      and analyzing the same PPC file using an x86 perf binary shows:
      
              rsyslogd  1212/1210
      
      The problem is that the swap_op method for samples is
      perf_event__all64_swap which assumes all elements in the sample_data
      struct are u64s. cpu, tid and pid are u32s and need to be handled
      individually. Given that the swap is done before the sample is parsed,
      the simplest solution is to undo the 64-bit swap of those elements when
      the sample is parsed and do the proper swap.
      
      The RAW data field is generic and perf cannot have programmatic knowledge
      of how to treat that data. Instead a warning is given to the user.
      
      Thanks to Anton Blanchard for providing a data file for a mult-CPU
      PPC system so I could verify the fix for the CPU fields.
      
      v3 -> v4:
      - fixed use of WARN_ONCE
      
      v2 -> v3:
      - used WARN_ONCE for message regarding raw data
      - removed struct wrapper around union
      - fixed whitespace issues
      
      v1 -> v2:
      - added a union for undoing the byte-swap on u64 and redoing swap on
        u32's to address compiler errors (see git commit 65014ab3)
      
      Cc: Anton Blanchard <anton@samba.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1315321946-16993-1-git-send-email-dsahern@gmail.comSigned-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      936be503
    • Anton Blanchard's avatar
      perf sort: Fix symbol sort output by separating unresolved samples by type · 6bb8f311
      Anton Blanchard authored
      I took a profile that suggested 60% of total CPU time was in the
      hypervisor:
      
      ...
          60.20%  [H] 0x33d43c
           4.43%  [k] ._spin_lock_irqsave
           1.07%  [k] ._spin_lock
      
      Using perf stat to get the user/kernel/hypervisor breakdown contradicted
      this.
      
      The problem is we merge all unresolved samples into the one unknown
      bucket. If add a comparison by sample type to sort__sym_cmp we get the
      real picture:
      
      ...
          57.11%  [.] 0x80fbf63c
           4.43%  [k] ._spin_lock_irqsave
           1.07%  [k] ._spin_lock
           0.65%  [H] 0x33d43c
      
      So it was almost all userspace, not hypervisor as the initial profile
      suggested.
      
      I found another issue while adding this. Symbol sorting sometimes shows
      multiple entries for the unknown bucket:
      
      ...
          16.65%  [.] 0x6cd3a8
           7.25%  [.] 0x422460
           5.37%  [.] yylex
           4.79%  [.] malloc
           4.78%  [.] _int_malloc
           4.03%  [.] _int_free
           3.95%  [.] hash_source_code_string
           2.82%  [.] 0x532908
           2.64%  [.] 0x36b538
           0.94%  [H] 0x8000000000e132a4
           0.82%  [H] 0x800000000000e8b0
      
      This happens because we aren't consistent with our sorting. On
      one hand we check to see if both symbols match and for two unresolved
      samples sym is NULL so we match:
      
              if (left->ms.sym == right->ms.sym)
                      return 0;
      
      On the other hand we use sample IP for unresolved samples when
      comparing against a symbol:
      
             ip_l = left->ms.sym ? left->ms.sym->start : left->ip;
             ip_r = right->ms.sym ? right->ms.sym->start : right->ip;
      
      This means unresolved samples end up spread across the rbtree and we
      can't merge them all.
      
      If we use cmp_null all unresolved samples will end up in the one bucket
      and the output makes more sense:
      
      ...
          39.12%  [.] 0x36b538
           5.37%  [.] yylex
           4.79%  [.] malloc
           4.78%  [.] _int_malloc
           4.03%  [.] _int_free
           3.95%  [.] hash_source_code_string
           2.26%  [H] 0x800000000000e8b0
      Acked-by: default avatarEric B Munson <emunson@mgebm.net>
      Cc: Eric B Munson <emunson@mgebm.net>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Ian Munsie <imunsie@au1.ibm.com>
      Link: http://lkml.kernel.org/r/20110831115145.4f598ab2@krytenSigned-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6bb8f311
    • Anton Blanchard's avatar
      perf symbols: Synthesize anonymous mmap events · 6a0e55d8
      Anton Blanchard authored
      perf_event__synthesize_mmap_events does not create anonymous mmap events
      even though the kernel does. As a result an already running application
      with dynamically created code will not get profiled - all samples end up
      in the unknown bucket.
      
      This patch skips any entries with '[' in the name to avoid adding events
      for special regions (eg the vsyscall page). All other executable mmaps
      are assumed to be anonymous and an event is synthesized.
      Acked-by: default avatarPekka Enberg <penberg@kernel.org>
      Cc: Eric B Munson <emunson@mgebm.net>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Pekka Enberg <penberg@cs.helsinki.fi>
      Link: http://lkml.kernel.org/r/20110830091506.60b51fe8@krytenSigned-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6a0e55d8
    • David Ahern's avatar
      perf record: Create events initially disabled and enable after init · 764e16a3
      David Ahern authored
      perf-record currently creates events enabled. When doing a system wide
      collection (-a arg) this causes data collection for perf's
      initialization activities -- eg., perf_event__synthesize_threads().
      
      For some events (e.g., context switch S/W event or tracepoints like
      syscalls) perf's initialization causes a lot of events to be captured
      frequently generating "Check IO/CPU overload!" warnings on larger
      systems (e.g., 2 socket, quad core, hyperthreading).
      
      perf's initialization phase can be skipped by creating events
      disabled and then enabling them once the initialization is done.
      
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/1314289075-14706-1-git-send-email-dsahern@gmail.comSigned-off-by: default avatarDavid Ahern <dsahern@gmail.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      764e16a3
    • Anton Blanchard's avatar
      perf symbols: Add some heuristics for choosing the best duplicate symbol · 694bf407
      Anton Blanchard authored
      Try and pick the best symbol based on a few heuristics:
      
      -  Prefer a non weak symbol over a weak one
      -  Prefer a global symbol over a non global one
      -  Prefer a symbol with less underscores (idea taken from kallsyms.c)
      -  If all else fails, choose the symbol with the longest name
      
      Cc: Eric B Munson <emunson@mgebm.net>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20110824065243.161953371@samba.orgSigned-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      694bf407
    • Anton Blanchard's avatar
      perf symbols: Preserve symbol scope when parsing /proc/kallsyms · 31877908
      Anton Blanchard authored
      kallsyms__parse capitalises the symbol type, so every symbol is marked
      global. Remove this and fix symbol_type__is_a to handle both local and
      global symbols.
      
      Cc: Eric B Munson <emunson@mgebm.net>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20110824065243.077125989@samba.orgSigned-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      31877908
    • Anton Blanchard's avatar
      perf symbols: /proc/kallsyms does not sort module symbols · 3f5a4272
      Anton Blanchard authored
      kallsyms__parse assumes that /proc/kallsyms is sorted and sets the end
      of the previous symbol to the start of the current one.
      
      Unfortunately module symbols are not sorted, eg:
      
      ffffffffa0081f30 t e1000_clean_rx_irq   [e1000e]
      ffffffffa00817a0 t e1000_alloc_rx_buffers       [e1000e]
      
      Some symbols end up with a negative length and others have a length
      larger than they should. This results in confusing perf output.
      
      We already have a function to fixup the end of zero length symbols so
      use that instead.
      
      Cc: Eric B Munson <emunson@mgebm.net>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20110824065242.969681349@samba.orgSigned-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      3f5a4272
    • Anton Blanchard's avatar
      perf symbols: Fix ppc64 SEGV in dso__load_sym with debuginfo files · adb09184
      Anton Blanchard authored
      64bit PowerPC debuginfo files have an empty function descriptor section.
      I hit a SEGV when perf tried to use this section for symbol resolution.
      
      To fix this we need to check the section is valid and we can do this by
      checking for type SHT_PROGBITS.
      
      Cc: <stable@kernel.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Eric B Munson <emunson@mgebm.net>
      Link: http://lkml.kernel.org/r/20110824065242.895239970@samba.orgSigned-off-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      adb09184
    • Masami Hiramatsu's avatar
      perf probe: Fix regression of variable finder · f66fedcb
      Masami Hiramatsu authored
      Fix to call convert_variable() if previous call does not fail.
      
      To call convert_variable, it ensures "ret" is 0. However, since
      "ret" has the return value of synthesize_perf_probe_arg() which
      always returns positive value if it succeeded, perf probe doesn't
      call convert_variable(). This will cause a SEGV when we add an
      event with arguments.
      
      This has to be fixed as it ensures "ret" is greater than 0
      (or not negative).
      
      This regression has been introduced by my previous patch, f182e3e1.
      
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20110820053922.3286.65805.stgit@fedora15Signed-off-by: default avatarMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f66fedcb
  2. 21 Sep, 2011 14 commits
  3. 20 Sep, 2011 16 commits