Skip to content
  1. Nov 19, 2014
    • Adrian Hunter's avatar
      perf tools: Add perf-read-vdso32 and perf-read-vdsox32 to .gitignore · 4b34f19b
      Adrian Hunter authored
      
      
      Recently added executables Add perf-read-vdso32 and perf-read-vdsox32
      need to be added to .gitignore.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415715423-15563-3-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4b34f19b
    • Adrian Hunter's avatar
      perf evlist: Do not poll events that use the system_wide flag · f90d194a
      Adrian Hunter authored
      
      
      The system_wide flag causes a selected event to be opened always without
      a pid.
      
      Consequently it will never get a POLLHUP, but it is used for tracking in
      combination with other events, so it should not need to be polled
      anyway.
      
      Therefore don't add it for polling.
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415715423-15563-2-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f90d194a
    • Jiri Olsa's avatar
      perf evsel: Fix ftrace:function event recording · f140373b
      Jiri Olsa authored
      Following patch fails (-EINVAL) ftrace:function with enabled user
      space callchains:
        cfa77bc4
      
       perf: Disallow user-space callchains for function trace events
      
      We need to follow in perf tool itself and explicitly set the
      perf_event_attr::exclude_callchain_user flag for ftrace:function
      event.
      
      Reported-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/1415899263-24820-1-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f140373b
    • Kan Liang's avatar
      perf diff: Add missing handler for PERF_RECORD_MMAP2 events · 68ca9d65
      Kan Liang authored
      
      
      Without mmap2, perf diff fails to find the symbol name. The default
      symbol sort key doesn't work well.
      
      Signed-off-by: default avatarKan Liang <kan.liang@intel.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1416328700-1836-2-git-send-email-kan.liang@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      68ca9d65
    • Arnaldo Carvalho de Melo's avatar
      perf hists: Fix up srcline histogram key formatting · b2d53671
      Arnaldo Carvalho de Melo authored
      Problem introduced in:
      
        commit 5b591669
      
       "perf report: Honor column width setting"
      
      Where the left justification signal was after the width, which ended up,
      when the width was, say, 11, always printing:
      
      	%11.11-s
      
      Instead of src:line left justified and limited to 11 chars.
      
      Resulting in a like:
      
          70.93%  %11.11-s  [.] f2                     tcall
      
      When it should instead be:
      
          70.93%  tcall.c:5    [.] f2                     tcall
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <andi@firstfloor.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-2xnt0vqkoox52etq2qhyetr0@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b2d53671
    • Andi Kleen's avatar
      perf annotate: Support source line numbers in annotate · e592488c
      Andi Kleen authored
      
      
      With srcline key/sort'ing it's useful to have line numbers in the
      annotate window. This patch implements this.
      
      Use objdump -l to request the line numbers and save them in the line
      structure. Then the browser displays them for source lines.
      
      The line numbers are not displayed by default, but can be toggled on
      with 'k'
      
      There is one unfortunate problem with this setup. For lines not
      containing source and which are outside functions objdump -l reports
      line numbers off by a few: it always reports the first line number in
      the next function even for lines that are outside the function.
      
      I haven't found a nice way to detect/correct this. Probably objdump has
      to be fixed.
      
      See https://sourceware.org/bugzilla/show_bug.cgi?id=16433
      
      The line numbers are still useful even with these problems, as most are
      correct and the ones which are not are nearby.
      
      v2: Fix help text. Handle (discriminator...) output in objdump.
      Left align the line numbers.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1415844328-4884-9-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e592488c
    • Andi Kleen's avatar
      perf tools: Only print base source file for srcline · 2de21768
      Andi Kleen authored
      
      
      For perf report with --sort srcline only print the base source file
      name. This makes the results generally fit much better to the screen.
      The path is usually not that useful anyways because it is often from
      different systems.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1415844328-4884-8-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2de21768
    • Andi Kleen's avatar
      perf callchain: Use a common function to resolve symbol or name · 2989ccaa
      Andi Kleen authored
      
      
      Refactor the duplicated code to resolve the symbol name or
      the address of a symbol into a single function.
      
      Used in next patch to add common functionality.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1415844328-4884-6-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2989ccaa
    • Andi Kleen's avatar
      perf callchain: Use al.addr to set up call chain · 5550171b
      Andi Kleen authored
      
      
      Use the relative address, this makes get_srcline work correctly in the
      end.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1415844328-4884-4-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5550171b
    • Andi Kleen's avatar
      perf callchain: Factor out adding new call chain entries · 37592b8a
      Andi Kleen authored
      
      
      Move the code to resolve and add a new callchain entry into a new
      add_callchain_ip function. This will be used in the next patches to add
      LBRs too.
      
      No change in behavior.
      
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/1415844328-4884-2-git-send-email-andi@firstfloor.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      37592b8a
    • Adrian Hunter's avatar
      perf tools: Fix annotation with kcore · ee205503
      Adrian Hunter authored
      
      
      Patch "perf tools: Fix build-id matching on vmlinux" breaks annotation
      with kcore.  The problem is that symbol__annotate() first gets the
      filename based on the build-id which was previously not set.
      
      This patch provides a quick fix, however there should probably be only
      one way to determine the filename. e.g.  symbol__annotate() should use
      the same way as dso__data_fd().
      
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415700294-30816-1-git-send-email-adrian.hunter@intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ee205503
    • WANG Chao's avatar
      perf test: fix typo in python test · 887e73d7
      WANG Chao authored
      
      
      Library loading in python syntax should be 'import perf', not 'use perf'.
      
      Signed-off-by: default avatarWANG Chao <chaowang@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1415780826-13250-1-git-send-email-chaowang@redhat.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      887e73d7
    • Arnaldo Carvalho de Melo's avatar
      perf symbols: Fallback to kallsyms when using the minimal 'ELF' loader · 162bcc17
      Arnaldo Carvalho de Melo authored
      
      
      The minimal ELF loader should not return 1 when it manages to read the
      vmlinux build-id, it should instead return 0, meaning that it hasn't
      loaded any symbols, since it doesn't parses ELF at all.
      
      That way, the main symbol.c routines will understand that it is
      necessary to continue looking for a file with symbols, and when no
      libelf is linked, that means it will eventually try kallsyms.
      
      Reported-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Tested-by: default avatarPeter Zijlstra <peterz@infradead.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/20141111130326.GT18464@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      162bcc17
    • Namhyung Kim's avatar
      perf tools: Clean up libelf feature support code · 5e2d4d0e
      Namhyung Kim authored
      
      
      Current EXTLIBS contains -lelf by default and removes it when libelf is
      not detected.
      
      This is little bit confusing since we can now build perf without libelf
      so there's no need to handle it differently than other libraries.
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/1415337606-2186-3-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5e2d4d0e
    • Namhyung Kim's avatar
      perf build-id: Move disable_buildid_cache() to util/build-id.c · 73c5d224
      Namhyung Kim authored
      
      
      Also move static variable no_buildid_cache and check it in the
      perf_session_cache_build_ids().
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Aravinda Prasad <aravinda@linux.vnet.ibm.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Pekka Enberg <penberg@iki.fi>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
      Cc: systemtap@sourceware.org
      Link: http://lkml.kernel.org/r/1415368677-3794-1-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      73c5d224
  2. Nov 16, 2014
  3. Nov 12, 2014
  4. Nov 07, 2014
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo' of... · 322cd21f
      Ingo Molnar authored
      
      Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      Infrastructure changes:
      
       - Add gzip decompression support for kernel modules (Namhyung Kim)
      
       - More prep patches for Intel PT, including a a thread stack and
         more stuff made available via the database export mechanism (Adrian Hunter)
      
       - Optimize checking that tracepoint events are defined in perf script perl/python (Jiri Olsa)
      
       - Do not free pevent when deleting tracepoint evsel (Jiri Olsa)
      
       - Fix build-id matching for vmlinux (Namhyung Kim)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      322cd21f
    • Jiri Olsa's avatar
      perf evsel: Do not call pevent_free_format when deleting tracepoint · daa01794
      Jiri Olsa authored
      
      
      The libtraceevent library's main handle 'struct pevent' holds pointers
      of every event that was added to it via functions:
      
        pevent_parse_format
        pevent_parse_event
      
      We can't release struct event_format (call pevent_free_format)
      separately, because that breaks that pointers array mentioned above and
      another add_event call could end up with segfault.
      
      All added events are released within the handle cleanup in pevent_free.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Link: http://lkml.kernel.org/r/1415098538-1512-1-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      daa01794
    • Jiri Olsa's avatar
      perf script python: Removing event cache as it's no longer needed · adf5bcf3
      Jiri Olsa authored
      
      
      We don't need to maintain cache of 'struct event_format' objects.
      Currently the 'struct perf_evsel' holds this reference already.
      
      Adding events_defined bitmap to keep track of defined events, which is
      much cheaper than array of pointers.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1414363445-22370-3-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      adf5bcf3
    • Jiri Olsa's avatar
      perf script perl: Removing event cache as it's no longer needed · cdae2d1e
      Jiri Olsa authored
      
      
      We don't need to maintain cache of 'struct event_format' objects.
      Currently the 'struct perf_evsel' holds this reference already.
      
      Adding events_defined bitmap to keep track of defined events, which is
      much cheaper than array of pointers.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1414363445-22370-2-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      cdae2d1e
    • Jiri Olsa's avatar
      perf tools: Add test_and_set_bit function · 416c419c
      Jiri Olsa authored
      
      
      Set a bit and return its old value. Stolen from kernel sources, will be
      used in next patches.
      
      Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
      Acked-by: default avatarNamhyung Kim <namhyung@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@gmail.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1414363445-22370-1-git-send-email-jolsa@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      416c419c
  5. Nov 05, 2014
    • Namhyung Kim's avatar
      perf tools: Make vmlinux short name more like kallsyms short name · 96d78059
      Namhyung Kim authored
      
      
      The previous patch changed kernel dso name from '[kernel.kallsyms]' to
      vmlinux.  However it might add confusion to old users accustomed to the
      old name.  So change the short name to '[kernel.vmlinux]' to reduce such
      confusion.
      
      Before:
        # Overhead  Command         Shared Object            Symbol
        # ........  ..............  .......................  ...............................
        #
             9.83%  swapper         vmlinux                  [k] intel_idle
             4.10%  awk             libc-2.20.so             [.] __strcmp_sse2
             1.86%  sed             libc-2.20.so             [.] __strcmp_sse2
             1.78%  netctl-auto     libc-2.20.so             [.] __strcmp_sse2
             1.23%  netctl-auto     libc-2.20.so             [.] __mbrtowc
             1.21%  firefox         libxul.so                [.] 0x00000000024b62bd
             1.20%  swapper         vmlinux                  [k] cpuidle_enter_state
             1.03%  sleep           vmlinux                  [k] copy_user_generic_unrolled
      
      After:
        # Overhead  Command         Shared Object            Symbol
        # ........  ..............  .......................  ...............................
        #
             9.83%  swapper         [kernel.vmlinux]         [k] intel_idle
             4.10%  awk             libc-2.20.so             [.] __strcmp_sse2
             1.86%  sed             libc-2.20.so             [.] __strcmp_sse2
             1.78%  netctl-auto     libc-2.20.so             [.] __strcmp_sse2
             1.23%  netctl-auto     libc-2.20.so             [.] __mbrtowc
             1.21%  firefox         libxul.so                [.] 0x00000000024b62bd
             1.20%  swapper         [kernel.vmlinux]         [k] cpuidle_enter_state
             1.03%  sleep           [kernel.vmlinux]         [k] copy_user_generic_unrolled
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-9-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      96d78059
    • Namhyung Kim's avatar
      perf tools: Fix build-id matching on vmlinux · b837a8bd
      Namhyung Kim authored
      There's a problem on finding correct kernel symbols when perf report
      runs on a different kernel.  Although a part of the problem was solved
      by the prior commit 0a7e6d1b
      
       ("perf tools: Check recorded kernel
      version when finding vmlinux"), there's a remaining problem still.
      
      When perf records samples, it synthesizes the kernel map using
      machine__mmap_name() and ref_reloc_sym like "[kernel.kallsyms]_text".
      You can easily see it using 'perf report -D' command.
      
      After finishing record, it goes through the recorded events to find
      maps/dsos actually used.  And then record build-id info of them.
      
      During this process, it needs to load symbols in a dso and it'd call
      dso__load_vmlinux_path() since the default value of the symbol_conf.
      try_vmlinux_path is true.  However it changes dso->long_name to a real
      path of the vmlinux file (e.g. /lib/modules/3.16.4/build/vmlinux) if one
      is running on a custom kernel.
      
      It resulted in that perf report reads the build-id of the vmlinux, but
      cannot use it since it only knows about the [kernel.kallsyms] map.  It
      then falls back to possible vmlinux paths by using the recorded kernel
      version (in case of a recent version) or a running kernel silently.
      
      Even with the recent tools, this still has a possibility of breaking
      the result.  As the build directory is a symbolic link, if one built a
      new kernel in the same directory with different source/config, the old
      link to vmlinux will point the new file.  So it's absolutely needed to
      use build-id when finding a kernel image.
      
      In this patch, it's now changed to try to search a kernel dso in the
      existing dso list which was constructed during build-id table parsing
      so it'll always have a build-id.  If not found, search "[kernel.kallsyms]".
      
      Before:
      
        $ perf report
        # Children      Self  Command  Shared Object      Symbol
        # ........  ........  .......  .................  ...............................
        #
            72.15%     0.00%  swapper  [kernel.kallsyms]  [k] set_curr_task_rt
            72.15%     0.00%  swapper  [kernel.kallsyms]  [k] native_calibrate_tsc
            72.15%     0.00%  swapper  [kernel.kallsyms]  [k] tsc_refine_calibration_work
            71.87%    71.87%  swapper  [kernel.kallsyms]  [k] module_finalize
         ...
      
      After (for the same perf.data):
      
            72.15%     0.00%  swapper  vmlinux  [k] cpu_startup_entry
            72.15%     0.00%  swapper  vmlinux  [k] arch_cpu_idle
            72.15%     0.00%  swapper  vmlinux  [k] default_idle
            71.87%    71.87%  swapper  vmlinux  [k] native_safe_halt
         ...
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarIngo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/20140924073356.GB1962@gmail.com
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-8-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b837a8bd
    • Namhyung Kim's avatar
      perf record: Do not save pathname in ./debug/.build-id directory for vmlinux · 00dc8657
      Namhyung Kim authored
      
      
      When perf record finishes a session, it pre-processes samples in order
      to write build-id info from DSOs that had samples.
      
      During this process it'll call map__load() for the kernel map, and it
      ends up calling dso__load_vmlinux_path() which replaces dso->long_name.
      
      But this function checks kernel's build-id before searching vmlinux path
      so it'll end up with a cryptic name, the pathname for the entry in the
      ~/.debug cache, which can be confusing to users.
      
      This patch adds a flag to skip the build-id check during record, so
      that it'll have the original vmlinux path for the kernel dso->long_name,
      not the entry in the ~/.debug cache.
      
      Before:
        # perf record -va sleep 3
        mmap size 528384B
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.196 MB perf.data (~8545 samples) ]
        Looking at the vmlinux_path (7 entries long)
        Using /home/namhyung/.debug/.build-id/f0/6e17aa50adf4d00b88925e03775de107611551 for symbols
      
      After:
        # perf record -va sleep 3
        mmap size 528384B
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.193 MB perf.data (~8432 samples) ]
        Looking at the vmlinux_path (7 entries long)
        Using /lib/modules/3.16.4-1-ARCH/build/vmlinux for symbols
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-7-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      00dc8657
    • Namhyung Kim's avatar
      perf build-id: Move build-id related functions to util/build-id.c · e195fac8
      Namhyung Kim authored
      
      
      It'd be better managing those functions in a separate place as
      util/header.c file is already big.
      
      It now exports following 3 functions to others:
      
        bool perf_session__read_build_ids(struct perf_session *session, bool with_hits);
        int perf_session__write_buildid_table(struct perf_session *session, int fd);
        int perf_session__cache_build_ids(struct perf_session *session);
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Link: http://lkml.kernel.org/r/545733E7.6010105@intel.com
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-5-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e195fac8
    • Namhyung Kim's avatar
      perf build-id: Rename dsos__write_buildid_table() · 714c9c4a
      Namhyung Kim authored
      
      
      The dsos__write_buildid_table() is not use struct dso and it mostly
      uses perf_session struct.
      
      So rename it to perf_session__write_buildid_ table() so that it
      corresponds to other related functions such as
      perf_session__read_build_ids() and perf_session__cache_build_ids().
      
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung.kim@lge.com>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/r/1415063674-17206-4-git-send-email-namhyung@kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      714c9c4a