1. 26 2月, 2015 2 次提交
  2. 11 2月, 2015 1 次提交
  3. 21 1月, 2015 3 次提交
  4. 17 1月, 2015 1 次提交
  5. 02 1月, 2015 1 次提交
    • M
      perf probe: Fix to fall back to find probe point in symbols · 906451b9
      Masami Hiramatsu 提交于
      Fix to fall back to find a probe point in symbols if perf fails to find
      it in debuginfo.
      
      This can happen when the target function is an alias of another
      function. Such alias doesn't have an entry in debuginfo but in symbols.
      
      David Ahern reported this problem in https://lkml.org/lkml/2014/12/29/355
      
      I ensured the problem and deeper investigation discovers it.
       -----
       eu-readelf --debug-dump=info /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.19.so | grep \"malloc\" -A6
                   name                 (strp) "malloc"
                   decl_file            (data1) 25
                   decl_line            (data2) 466
                   prototyped           (flag_present)
                   type                 (ref4) [  81b5]
                   declaration          (flag_present)
       [  8f58]      formal_parameter
       --
                   name                 (strp) "malloc"
                   decl_file            (data1) 23
                   decl_line            (data2) 466
                   prototyped           (flag_present)
                   type                 (ref4) [  9f4a]
                   declaration          (flag_present)
                   sibling              (ref4) [  bb29]
       ...
       -----
      All these entires have no instances (all of them are declarations)
      This is why the perf probe failed to find it in debuginfo.
      
      However, there are some malloc instances in symbols.
       -----
       eu-readelf --symbols /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.19.so | grep malloc$
        1181: 0000000000080700   5332 FUNC    LOCAL  DEFAULT       12 _int_malloc
        4537: 00000000000831d0    339 FUNC    LOCAL  DEFAULT       12 __GI___libc_malloc
        5545: 00000000000831d0    339 FUNC    LOCAL  DEFAULT       12 __malloc
        6063: 00000000000831d0    339 FUNC    GLOBAL DEFAULT       12 malloc
        7302: 00000000000831d0    339 FUNC    GLOBAL DEFAULT       12 __libc_malloc
       -----
      As you an see, malloc and __libc_malloc have same address, and actually
      __libc_malloc has an entry in debuginfo. So you can set up a probe on
      __libc_malloc.
      
      To fix this problem shortly, perf probe simply falls back to find probe
      point(malloc) in symbols if it is not found in debuginfo.
      Reported-by: NDavid Ahern <dsahern@gmail.com>
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20141231062747.2087.80961.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      906451b9
  6. 29 10月, 2014 1 次提交
  7. 30 9月, 2014 1 次提交
    • W
      perf symbols: Encapsulate dsos list head into struct dsos · 8fa7d87f
      Waiman Long 提交于
      This is a precursor patch to enable long name searching of DSOs using
      a rbtree.
      
      In this patch, a new dsos structure is created which contains only a
      list head structure for the moment.
      
      The new dsos structure is used, in turn, in the machine structure for
      the user_dsos and kernel_dsos fields.
      
      Only the following 3 dsos functions are modified to accept the new dsos
      structure parameter instead of list_head:
      
       - dsos__add()
       - dsos__find()
       - __dsos__findnew()
      Signed-off-by: NWaiman Long <Waiman.Long@hp.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Don Zickus <dzickus@redhat.com>
      Cc: Douglas Hatch <doug.hatch@hp.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Scott J Norton <scott.norton@hp.com>
      Link: http://lkml.kernel.org/r/1412021249-19201-2-git-send-email-Waiman.Long@hp.com
      [ Move struct dsos to dso.h to reduce the dso methods depends on machine.h ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8fa7d87f
  8. 18 9月, 2014 1 次提交
    • M
      perf probe: Do not access kallsyms when analyzing user binaries · 2b394bc4
      Masami Hiramatsu 提交于
      Do not access kallsyms to show available variables and show source lines
      in user binaries.
      
      This behavior always requires the root privilege when sysctl sets
      kernel.kptr_restrict=1, but we don't need it just for analyzing user
      binaries.
      
      Without this patch (by normal user, kptr_restrict=1):
        ----
        $ perf probe -x ./perf -V add_cmdname
        Failed to init vmlinux path.
          Error: Failed to show vars.
        $ perf probe -x ./perf -L add_cmdname
        Failed to init vmlinux path.
          Error: Failed to show lines.
        ----
      
      With this patch:
        ----
        $ perf probe -x ./perf -V add_cmdname
        Available variables at add_cmdname
                @<perf_unknown_cmd_config+144>
                        (No matched variables)
                @<list_commands_in_dir+160>
                        (No matched variables)
                @<add_cmdname+0>
                        char*   name
                        size_t  len
                        struct cmdnames*        cmds
        $ perf probe -x ./perf -L add_cmdname
        <add_cmdname@/home/fedora/ksrc/linux-3/tools/perf/util/help.c:0>
              0  void add_cmdname(struct cmdnames *cmds, const char *name, size_t len)
              1  {
              2         struct cmdname *ent = malloc(sizeof(*ent) + len + 1);
      
              4         ent->len = len;
              5         memcpy(ent->name, name, len);
              6         ent->name[len] = 0;
        ...
        ----
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: david lerner <dlernerdroid@gmail.com>
      Cc: linux-perf-user@vger.kernel.org
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140917084054.3722.73975.stgit@kbuild-f20.novalocal
      [ Added missing 'bool user' argument to the !DWARF show_line_range() stub ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2b394bc4
  9. 15 8月, 2014 3 次提交
  10. 14 8月, 2014 3 次提交
    • N
      perf tools: Check recorded kernel version when finding vmlinux · 0a7e6d1b
      Namhyung Kim 提交于
      Currently vmlinux_path__init() only tries to find vmlinux file from
      current directory, /boot and some canonical directories with version
      number of the running kernel.  This can be a problem when reporting old
      data recorded on a kernel version not running currently.
      
      We can use --symfs option for this but it's annoying for user to do it
      always.  As we already have the info in the perf.data file, it can be
      changed to use it for the search automatically.
      
      Before:
      
        $ perf report
        ...
        # Samples: 4K of event 'cpu-clock'
        # Event count (approx.): 1067250000
        #
        # Overhead  Command     Shared Object      Symbol
        # ........  ..........  .................  ..............................
            71.87%     swapper  [kernel.kallsyms]  [k] recover_probed_instruction
      
      After:
      
        # Overhead  Command     Shared Object      Symbol
        # ........  ..........  .................  ....................
            71.87%     swapper  [kernel.kallsyms]  [k] native_safe_halt
      
      This requires to change signature of symbol__init() to receive struct
      perf_session_env *.
      Reported-by: NMinchan Kim <minchan@kernel.org>
      Signed-off-by: NNamhyung 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: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Minchan Kim <minchan@kernel.org>
      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/1407825645-24586-14-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0a7e6d1b
    • M
      perf probe: Fix --del option to delete events only with uprobe events · 467ec085
      Masami Hiramatsu 提交于
      Current perf probe --del doesn't work if only CONFIG_UPROBE_EVENTS=y
      because it aborts when it fails to open kprobe_events file before
      checking uprobe_events file.
      
      This fixes --del option to delete dynamic events if it can open either
      kprobe_events or uprobe_events. Only if it failed to open both of them,
      it shows an error message and aborts.
      
      Without this patch, if we run perf probe -d on the kernel configured
      with CONFIG_KPROBE_EVENTS=n and CONFIG_UPROBE_EVENTS=y,
      
        # perf probe -d \*
        kprobe_events file does not exist - please rebuild kernel with CONFIG_KPROBE_EVENTS.
          Error: Failed to delete events.
      
      With this patch,
      
        # perf probe -d \*
        Removed event: probe_perf:alloc_event
      
      Changes in v2:
       - Use strerror_r instead of strerror.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Naohiro Aota <naota@elisp.net>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20140813161250.26440.24028.stgit@kbuild-fedora.novalocalSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      467ec085
    • M
      perf probe: Fix --list option to show events only with uprobe events · 5e45187c
      Masami Hiramatsu 提交于
      Current perf probe --list doesn't work if only CONFIG_UPROBE_EVENTS=y
      because it aborts when it fails to open kprobe_events file before
      checking uprobe_events file.
      
      This fixes --list option to show dynamic events if it can open either
      kprobe_events or uprobe_events. Only if it failed to open both of them,
      it shows an error message and aborts.
      
      Without this patch, if we run perf probe -l on the kernel configured
      with CONFIG_KPROBE_EVENTS=n and CONFIG_UPROBE_EVENTS=y,
      
        # perf probe -l
        /sys/kernel/debug/tracing/kprobe_events file does not exist - please rebuild ker
          Error: Failed to show event list.
      
      With this patch,
      
        # perf probe -l
          probe_perf:alloc_event (on alloc_event@lib/traceevent/event-parse.c in /home/fedora/ksrc/linux-3/tools/perf/perf)
      
      Changes in v2:
       - Use strerror_r instead of strerror.
      Reported-by: NNaohiro Aota <naota@elisp.net>
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Naohiro Aota <naota@elisp.net>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20140813161248.26440.84370.stgit@kbuild-fedora.novalocalSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5e45187c
  11. 10 6月, 2014 2 次提交
    • M
      perf probe: Improve error messages in --line option · 5ee05b88
      Masami Hiramatsu 提交于
      Improve error messages of 'perf probe --line' mode.
      
      Currently 'perf probe' shows the "Debuginfo analysis failed" message with
      an error code when the given symbol is not found:
      
        -----
        # perf probe -L page_cgroup_init_flatmem
        Debuginfo analysis failed. (-2)
          Error: Failed to show lines.
        -----
      
      But -2 (-ENOENT) means that the given source line or function was not
      found. With this patch, 'perf probe' shows the correct error message:
      
        -----
        # perf probe -L page_cgroup_init_flatmem
        Specified source line is not found.
          Error: Failed to show lines.
        -----
      
      There is also another debug error code is shown in the same function
      after get_real_path(). This removes that too.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      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/20140606071406.6788.47850.stgit@kbuild-fedora.novalocalSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5ee05b88
    • M
      perf probe: Improve an error message of perf probe --vars mode · 69e96eaa
      Masami Hiramatsu 提交于
      Fix an error message when failed to find given address in --vars
      mode.
      
      Without this fix, perf probe -V doesn't show the final "Error"
      message if it fails to find given source line. Moreover, it
      tells it fails to find "variables" instead of the source line.
        -----
        # perf probe -V foo@bar
        Failed to find variables at foo@bar (0)
        -----
      The result also shows mysterious error code. Actually the error
      returns 0 or -ENOENT means that it just fails to find the address
      of given source line. (0 means there is no matching address,
      and -ENOENT means there is an entry(DIE) but it has no instance,
      e.g. an empty inlined function)
      
      This fixes it to show what happened and the final error message
      as below.
        -----
        # perf probe -V foo@bar
        Failed to find the address of foo@bar
          Error: Failed to show vars.
        -----
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.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/20140606071359.6788.84716.stgit@kbuild-fedora.novalocalSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      69e96eaa
  12. 18 2月, 2014 11 次提交
    • M
      perf probe: Support distro-style debuginfo for uprobe · a15ad2f5
      Masami Hiramatsu 提交于
      Support distro-style debuginfo supported by dso for setting uprobes.
      Note that this tries to find a debuginfo file based on the real path of
      the target binary. If the debuginfo is not correctly installed on the
      system, this can not find it.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053227.29635.54434.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a15ad2f5
    • M
      perf probe: Allow to add events on the local functions · eb948e50
      Masami Hiramatsu 提交于
      Allow to add events on the local functions without debuginfo.
      (With the debuginfo, we can add events even on inlined functions)
      Currently, probing on local functions requires debuginfo to
      locate actual address. It is also possible without debuginfo since
      we have symbol maps.
      
      Without this change;
        ----
        # ./perf probe -a t_show
        Added new event:
          probe:t_show         (on t_show)
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe:t_show -aR sleep 1
      
        # ./perf probe -x perf -a identity__map_ip
        no symbols found in /kbuild/ksrc/linux-3/tools/perf/perf, maybe install a debug package?
        Failed to load map.
          Error: Failed to add events. (-22)
        ----
      As the above results, perf probe just put one event
      on the first found symbol for kprobe event. Moreover,
      for uprobe event, perf probe failed to find local
      functions.
      
      With this change;
        ----
        # ./perf probe -a t_show
        Added new events:
          probe:t_show         (on t_show)
          probe:t_show_1       (on t_show)
          probe:t_show_2       (on t_show)
          probe:t_show_3       (on t_show)
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe:t_show_3 -aR sleep 1
      
        # ./perf probe -x perf -a identity__map_ip
        Added new events:
          probe_perf:identity__map_ip (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
          probe_perf:identity__map_ip_1 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
          probe_perf:identity__map_ip_2 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
          probe_perf:identity__map_ip_3 (on identity__map_ip in /kbuild/ksrc/linux-3/tools/perf/perf)
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe_perf:identity__map_ip_3 -aR sleep 1
        ----
      Now we succeed to put events on every given local functions
      for both kprobes and uprobes. :)
      
      Note that this also introduces some symbol rbtree
      iteration macros; symbols__for_each, dso__for_each_symbol,
      and map__for_each_symbol. These are for walking through
      the symbol list in a map.
      
      Changes from v2:
        - Fix add_exec_to_probe_trace_events() not to convert address
          to tp->symbol any more.
        - Fix to set kernel probes based on ref_reloc_sym.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053225.29635.15026.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      eb948e50
    • M
      perf probe: Show source-level or symbol-level info for uprobes · 5a6f6314
      Masami Hiramatsu 提交于
      Show source-level or symbol-level information for uprobe events.
      
      Without this change;
        # ./perf probe -l
          probe_perf:dso__load_vmlinux (on 0x000000000006d110 in /kbuild/ksrc/linux-3/tools/perf/perf)
      
      With this change;
        # ./perf probe -l
          probe_perf:dso__load_vmlinux (on dso__load_vmlinux@util/symbol.c in /kbuild/ksrc/linux-3/tools/perf/perf)
      
      Changes from v2:
       - Update according to previous patches.
      
      Changes from v1:
       - Rewrite the code based on new series.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053223.29635.51280.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5a6f6314
    • M
      perf probe: Show appropriate symbol for ref_reloc_sym based kprobes · 8f33f7de
      Masami Hiramatsu 提交于
      Show appropriate symbol for ref_reloc_sym based kprobes instead of
      refpoint+offset when perf-probe -l runs without debuginfo.
      
      Without this change:
        # ./perf probe -l
          probe:t_show         (on _stext+889880 with m v)
          probe:t_show_1       (on _stext+928568 with m v t)
          probe:t_show_2       (on _stext+969512 with m v fmt)
          probe:t_show_3       (on _stext+1001416 with m v file)
      
      With this change:
        # ./perf probe -l
          probe:t_show         (on t_show with m v)
          probe:t_show_1       (on t_show with m v t)
          probe:t_show_2       (on t_show with m v fmt)
          probe:t_show_3       (on t_show with m v file)
      
      Changes from v2:
       - Check ref_reloc_sym to find correct unrelocated address.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053220.29635.81819.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8f33f7de
    • M
      perf probe: Find given address from offline dwarf · f90acac7
      Masami Hiramatsu 提交于
      Find the given address from offline dwarfs instead of online kernel
      dwarfs.
      
      On the KASLR enabled kernel, the kernel text section is loaded with
      random offset, and the debuginfo__new_online_kernel can't handle it. So
      let's move to the offline dwarf loader instead of using the online dwarf
      loader.
      
      As a result, since we don't need debuginfo__new_online_kernel any more,
      this also removes the functions related to that.
      
      Without this change;
      
        # ./perf probe -l
          probe:t_show         (on _stext+901288 with m v)
          probe:t_show_1       (on _stext+939624 with m v t)
          probe:t_show_2       (on _stext+980296 with m v fmt)
          probe:t_show_3       (on _stext+1014392 with m v file)
      
      With this change;
      
        # ./perf probe -l
          probe:t_show         (on t_show@linux-3/kernel/trace/ftrace.c with m v)
          probe:t_show_1       (on t_show@linux-3/kernel/trace/trace.c with m v t)
          probe:t_show_2       (on t_show@kernel/trace/trace_printk.c with m v fmt)
          probe:t_show_3       (on t_show@kernel/trace/trace_events.c with m v file)
      
      Changes from v2:
       - Instead of retrying, directly opens offline dwarf.
       - Remove debuginfo__new_online_kernel and related functions.
       - Refer map->reloc to get the correct address of a symbol.
       - Add a special case for handling ref_reloc_sym based address.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053218.29635.74821.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f90acac7
    • M
      perf probe: Use ref_reloc_sym based address instead of the symbol name · dfef99cd
      Masami Hiramatsu 提交于
      Since several local symbols can have same name (e.g. t_show), we need to
      use the relative address from the symbol referred by kmap->ref_reloc_sym
      instead of the target symbol name itself.
      
      Because the kernel address space layout randomize (kASLR) changes the
      absolute address of kernel symbols, we can't rely on the absolute
      address.
      
      Note that this works only with debuginfo.
      
      E.g. without this change;
        ----
        # ./perf probe -a "t_show \$vars"
        Added new events:
          probe:t_show         (on t_show with $vars)
          probe:t_show_1       (on t_show with $vars)
          probe:t_show_2       (on t_show with $vars)
          probe:t_show_3       (on t_show with $vars)
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe:t_show_3 -aR sleep 1
        ----
      OK, we have 4 different t_show()s. All functions have
      different arguments as below;
        ----
        # cat /sys/kernel/debug/tracing/kprobe_events
        p:probe/t_show t_show m=%di:u64 v=%si:u64
        p:probe/t_show_1 t_show m=%di:u64 v=%si:u64 t=%si:u64
        p:probe/t_show_2 t_show m=%di:u64 v=%si:u64 fmt=%si:u64
        p:probe/t_show_3 t_show m=%di:u64 v=%si:u64 file=%si:u64
        ----
      However, all of them have been put on the *same* address.
        ----
        # cat /sys/kernel/debug/kprobes/list
        ffffffff810d9720  k  t_show+0x0    [DISABLED]
        ffffffff810d9720  k  t_show+0x0    [DISABLED]
        ffffffff810d9720  k  t_show+0x0    [DISABLED]
        ffffffff810d9720  k  t_show+0x0    [DISABLED]
        ----
      
      With this change;
        ----
        # ./perf probe -a "t_show \$vars"
        Added new events:
          probe:t_show         (on t_show with $vars)
          probe:t_show_1       (on t_show with $vars)
          probe:t_show_2       (on t_show with $vars)
          probe:t_show_3       (on t_show with $vars)
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe:t_show_3 -aR sleep 1
      
        # cat /sys/kernel/debug/tracing/kprobe_events
        p:probe/t_show _stext+889880 m=%di:u64 v=%si:u64
        p:probe/t_show_1 _stext+928568 m=%di:u64 v=%si:u64 t=%si:u64
        p:probe/t_show_2 _stext+969512 m=%di:u64 v=%si:u64 fmt=%si:u64
        p:probe/t_show_3 _stext+1001416 m=%di:u64 v=%si:u64 file=%si:u64
      
        # cat /sys/kernel/debug/kprobes/list
        ffffffffb50d95e0  k  t_show+0x0    [DISABLED]
        ffffffffb50e2d00  k  t_show+0x0    [DISABLED]
        ffffffffb50f4990  k  t_show+0x0    [DISABLED]
        ffffffffb50eccf0  k  t_show+0x0    [DISABLED]
        ----
      This time, each event is put in different address
      correctly.
      
      Note that currently this doesn't support address-based
      probe on modules (thus the probes on modules are symbol
      based), since it requires relative address probe syntax
      for kprobe-tracer, and it isn't implemented yet.
      
      One more note, this allows us to put events on correct
      address, but --list option should be updated to show
      correct corresponding source code.
      
      Changes from v2:
        - Refer kmap->ref_reloc_sym instead of "_stext".
        - Refer map->reloc to catch up the kASLR perf fix.
      
      Changes from v1:
        - Use _stext relative address instead of actual
          absolute address recorded in debuginfo.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053216.29635.22584.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dfef99cd
    • M
      perf probe: Show in what binaries/modules probes are set · fb226ccd
      Masami Hiramatsu 提交于
      Show the name of binary file or modules in which the probes are set with
      --list option.
      
      Without this change;
      
        # ./perf probe -m drm drm_av_sync_delay
        # ./perf probe -x perf dso__load_vmlinux
      
        # ./perf probe -l
          probe:drm_av_sync_delay (on drm_av_sync_delay)
          probe_perf:dso__load_vmlinux (on 0x000000000006d110)
      
      With this change;
      
        # ./perf probe -l
          probe:drm_av_sync_delay (on drm_av_sync_delay in drm)
          probe_perf:dso__load_vmlinux (on 0x000000000006d110 in /kbuild/ksrc/linux-3/tools/perf/perf)
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053213.29635.69948.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fb226ccd
    • M
      perf probe: Unify show_available_functions for uprobes/kprobes · 2df58634
      Masami Hiramatsu 提交于
      Unify show_available_functions for uprobes/kprobes to cleanup and reduce
      the code. This also improves error messages.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053211.29635.20563.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2df58634
    • M
      perf probe: Replace line_list with intlist · 5a62257a
      Masami Hiramatsu 提交于
      Replace line_list (struct line_node) with intlist for reducing similar
      codes.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053209.29635.81043.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5a62257a
    • M
      perf probe: Remove incorrect symbol check for --list · f49540b1
      Masami Hiramatsu 提交于
      Remove unneeded symbol check for --list option.
      
      This code actually checks whether the given symbol exists in the kernel.
      But this is incorrect for online kernel/module and offline module too:
      
       - For online kernel/module, the kprobes itself already
        ensured the symbol exist in the kernel.
       - For offline module, this code can't access the offlined
        modules. Ignore it.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053206.29635.7453.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f49540b1
    • M
      perf probe: Fix to do exit call for symbol maps · ee45b6c2
      Masami Hiramatsu 提交于
      Some perf-probe commands do symbol_init() but doesn't do exit call.
      
      This fixes that to call symbol_exit() and releases machine if needed.
      
      This also merges init_vmlinux() and init_user_exec() because both of
      them are doing similar things.  (init_user_exec() just skips init
      vmlinux related symbol maps)
      
      Changes from v2:
       - Not to set symbol_conf.try_vmlinux_path in init_symbol_maps()
         (Thanks to Namhyung Kim!)
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140206053204.29635.28334.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ee45b6c2
  13. 10 2月, 2014 1 次提交
    • M
      perf probe: Do not add offset twice to uprobe address · 981a2379
      Masami Hiramatsu 提交于
      Fix perf-probe not to add offset value twice to uprobe probe address
      when post processing.
      
      The tevs[i].point.address struct member is the address of symbol+offset,
      but current perf-probe adjusts the point.address by adding the offset.
      
      As a result, the probe address becomes symbol+offset+offset. This may
      cause unexpected code corruption. Urgent fix is needed.
      
      Without this fix:
        ---
        # ./perf probe -x ./perf dso__load_vmlinux+4
        # ./perf probe -l
          probe_perf:dso__load_vmlinux (on 0x000000000006d2b8)
        # nm ./perf.orig | grep dso__load_vmlinux\$
        000000000046d0a0 T dso__load_vmlinux
        ---
      
      You can see the given offset is 3 but the actual probed address is
      dso__load_vmlinux+8.
      
      With this fix:
        ---
        # ./perf probe -x ./perf dso__load_vmlinux+4
        # ./perf probe -l
          probe_perf:dso__load_vmlinux (on 0x000000000006d2b4)
        ---
      
      Now the problem is fixed.
      
      Note: This bug is introduced by
      	commit fb7345bbSigned-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140205051858.6519.27314.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      981a2379
  14. 17 1月, 2014 3 次提交
  15. 14 1月, 2014 1 次提交
    • A
      perf probe: Fix build when DWARF support libraries not present · 1d027ee9
      Arnaldo Carvalho de Melo 提交于
      On a freshly installed system, after libelf-dev is installed we get:
      
          CC       /tmp/build/perf/util/probe-event.o
        util/probe-event.c: In function ‘try_to_find_probe_trace_events’:
        util/probe-event.c:753:46: error: unused parameter ‘target’ [-Werror=unused-parameter]
             int max_tevs __maybe_unused, const char *target)
                                                      ^
          CC       /tmp/build/perf/util/cgroup.o
        util/probe-event.c: At top level:
        util/probe-event.c:193:12: error: ‘get_text_start_address’ defined but not used [-Werror=unused-function]
         static int get_text_start_address(const char *exec, unsigned long *address)
                  ^
        cc1: all warnings being treated as errors
        make[1]: *** [/tmp/build/perf/util/probe-event.o] Error 1
        make[1]: *** Waiting for unfinished jobs....
        make: *** [install] Error 2
      
      Fix it by enclosing functions only used when those libraries are installed
      under the suitable preprocessor define and using __maybe_unused to a function
      that is only built when DWARF support is disabled.
      
      Problem introduced in this changeset:
      
        commit fb7345bb
        Author: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
        Date:   Thu Dec 26 05:41:53 2013 +0000
      
            perf probe: Support basic dwarf-based operations on uprobe events
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Mike Galbraith <efault@gmx.de>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: http://lkml.kernel.org/n/tip-73kc2fopt81517hrdgdra18o@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1d027ee9
  16. 28 12月, 2013 2 次提交
  17. 27 12月, 2013 1 次提交
  18. 26 12月, 2013 2 次提交
    • M
      perf probe: Support basic dwarf-based operations on uprobe events · fb7345bb
      Masami Hiramatsu 提交于
      Support basic dwarf(debuginfo) based operations for uprobe events.  With
      this change, perf probe can analyze debuginfo of user application binary
      to set up new uprobe event.
      
      This allows perf-probe --add(with local variables, line numbers) and
      --line works with -x option.  (Actually, --vars has already accepted -x
      option)
      
      For example, the following command shows the probe-able lines of a given
      user space function. Something that so far was only available in the
      'perf probe' tool for kernel space functions:
      
        # ./perf probe -x perf --line map__load
        <map__load@/home/fedora/ksrc/linux-2.6/tools/perf/util/map.c:0>
              0  int map__load(struct map *map, symbol_filter_t filter)
              1  {
              2         const char *name = map->dso->long_name;
                        int nr;
      
              5         if (dso__loaded(map->dso, map->type))
              6                 return 0;
      
              8         nr = dso__load(map->dso, map, filter);
              9         if (nr < 0) {
             10                 if (map->dso->has_build_id) {
      
      And this shows the available variables at the given line of the
      function.
      
        # ./perf probe -x perf --vars map__load:8
        Available variables at map__load:8
                @<map__load+96>
                        char*   name
                        struct map*     map
                        symbol_filter_t filter
                @<map__find_symbol+112>
                        char*   name
                        symbol_filter_t filter
                @<map__find_symbol_by_name+136>
                        char*   name
                        symbol_filter_t filter
                @<map_groups__find_symbol_by_name+176>
                        char*   name
                        struct map*     map
                        symbol_filter_t filter
      
      And lastly, we can now define probe(s) with all available
      variables on the given line:
      
        # ./perf probe -x perf --add 'map__load:8 $vars'
      
        Added new events:
          probe_perf:map__load (on map__load:8 with $vars)
          probe_perf:map__load_1 (on map__load:8 with $vars)
          probe_perf:map__load_2 (on map__load:8 with $vars)
          probe_perf:map__load_3 (on map__load:8 with $vars)
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe_perf:map__load_3 -aR sleep 1
      
        Changes from previous version:
         - Add examples in the patch description.
         - Use .text section start address and dwarf symbol address
           for calculating the offset of given symbol, instead of
           searching the symbol in symtab again.
           With this change, we can safely handle multiple local
           function instances (e.g. scnprintf in perf).
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David A. Long <dave.long@linaro.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: systemtap@sourceware.org
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20131226054152.22364.47021.stgit@kbuild-fedora.novalocalSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fb7345bb
    • M
      perf probe: Expand given path to absolute path · 8a613d40
      Masami Hiramatsu 提交于
      Expand given path to absolute path in the option parser, except for a
      module name.
      
      Since realpath at later stage in processing several probe point, can be
      called several times (even if currently doesn't, it can happen when we
      expands the feature), it is waste of the performance.
      
      Processing it once at the early stage can avoid that.
      
      Changes from previous one:
       - Fix not to print null string.
       - Allocate memory for given path/module name everytime.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Cc: systemtap@sourceware.org
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20131226054150.22364.12187.stgit@kbuild-fedora.novalocal
      [ Clarified the pr_warning message as per David Ahern's suggestion ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8a613d40