20 Apr, 2017

1 commit

  • There are places where we just need a forward declaration, and others
    were we need to include strlist.h and/or strfilter.h, reducing the
    impact of changes in headers on the build time, do it.

    Cc: Adrian Hunter
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Wang Nan
    Link: http://lkml.kernel.org/n/tip-zab42gbiki88y9k0csorxekb@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Arnaldo Carvalho de Melo
     

25 Nov, 2016

1 commit

  • Commit 0b3c2264ae30 ("perf symbols: Fix kallsyms perf test on ppc64le")
    refers struct symbol in probe_event.h, but forgets to include its
    definition. Gcc will complain about it when that definition is not
    added, by sheer luck, by some other header included before
    probe_event.h.

    Signed-off-by: Wang Nan
    Cc: Alexei Starovoitov
    Cc: He Kuang
    Cc: Naveen N. Rao
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/20161115040617.69788-4-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     

01 Sep, 2016

2 commits

  • Introduce helper function instead of inline code and replace hardcoded
    strings "$vars" and "$params" with their corresponding macros.

    perf_probe_with_var() is not declared as static since it will be called
    from different file in subsequent patch.

    Signed-off-by: Ravi Bangoria
    Acked-by: Masami Hiramatsu
    Cc: Alexander Shishkin
    Cc: Hemant Kumar
    Cc: Naveen N. Rao
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1470214725-5023-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Ravi Bangoria
     
  • Add --definition/-D option for showing the trace-event definition in
    stdout. This can be useful in debugging or combined with a shell script.

    e.g.
    ----
    # perf probe --definition 'do_sys_open $params'
    p:probe/do_sys_open _text+2261728 dfd=%di:s32 filename=%si:u64 flags=%dx:s32 mode=%cx:u16
    ----

    Suggested-and-Tested-by: Arnaldo Carvalho de Melo
    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/147214226712.23638.2240534040014013658.stgit@devbox
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

09 Aug, 2016

1 commit

  • Powerpc has Global Entry Point and Local Entry Point for functions. LEP
    catches call from both the GEP and the LEP. Symbol table of ELF contains
    GEP and Offset from which we can calculate LEP, but debuginfo does not
    have LEP info.

    Currently, perf prioritize symbol table over dwarf to probe on LEP for
    ppc64le. But when user tries to probe with function parameter, we fall
    back to using dwarf(i.e. GEP) and when function called via LEP, probe
    will never hit.

    For example:

    $ objdump -d vmlinux
    ...
    do_sys_open():
    c0000000002eb4a0: e8 00 4c 3c addis r2,r12,232
    c0000000002eb4a4: 60 00 42 38 addi r2,r2,96
    c0000000002eb4a8: a6 02 08 7c mflr r0
    c0000000002eb4ac: d0 ff 41 fb std r26,-48(r1)

    $ sudo ./perf probe do_sys_open
    $ sudo cat /sys/kernel/debug/tracing/kprobe_events
    p:probe/do_sys_open _text+3060904

    $ sudo ./perf probe 'do_sys_open filename:string'
    $ sudo cat /sys/kernel/debug/tracing/kprobe_events
    p:probe/do_sys_open _text+3060896 filename_string=+0(%gpr4):string

    For second case, perf probed on GEP. So when function will be called via
    LEP, probe won't hit.

    $ sudo ./perf record -a -e probe:do_sys_open ls
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.195 MB perf.data ]

    To resolve this issue, let's not prioritize symbol table, let perf
    decide what it wants to use. Perf is already converting GEP to LEP when
    it uses symbol table. When perf uses debuginfo, let it find LEP offset
    form symbol table. This way we fall back to probe on LEP for all cases.

    After patch:

    $ sudo ./perf probe 'do_sys_open filename:string'
    $ sudo cat /sys/kernel/debug/tracing/kprobe_events
    p:probe/do_sys_open _text+3060904 filename_string=+0(%gpr4):string

    $ sudo ./perf record -a -e probe:do_sys_open ls
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.197 MB perf.data (11 samples) ]

    Signed-off-by: Ravi Bangoria
    Acked-by: Masami Hiramatsu
    Cc: Alexander Shishkin
    Cc: Ananth N Mavinakayanahalli
    Cc: Balbir Singh
    Cc: Namhyung Kim
    Cc: Naveen N. Rao
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1470723805-5081-2-git-send-email-ravi.bangoria@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Ravi Bangoria
     

14 Jul, 2016

1 commit

  • To improve usability, support %[PROVIDER:]SDTEVENT format to add new
    probes on SDT and cached events.

    e.g.
    ----
    # perf probe -x /lib/libc-2.17.so %lll_lock_wait_private
    Added new event:
    sdt_libc:lll_lock_wait_private (on %lll_lock_wait_private in /usr/lib/libc-2.17.so)

    You can now use it in all perf tools, such as:

    perf record -e sdt_libc:lll_lock_wait_private -aR sleep 1

    # perf probe -l | more
    sdt_libc:lll_lock_wait_private (on __lll_lock_wait_private+21 in /usr/lib/libc-2.17.so)
    ----

    Note that this is not only for SDT events, but also normal
    events with event-name.

    e.g. define "myevent" on cache (-n doesn't add the real probe)
    ----
    # perf probe -x ./perf --cache -n --add 'myevent=dso__load $params'
    ----
    Reuse the "myevent" from cache as below.
    ----
    # perf probe -x ./perf %myevent
    ----

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Ananth N Mavinakayanahalli
    Cc: Brendan Gregg
    Cc: Hemant Kumar
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/146831788372.17065.3645054540325909346.stgit@devbox
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

16 Jun, 2016

1 commit

  • Add --cache option to cache the probe definitions. This just saves the
    result of the dwarf analysis to probe cache.

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Brendan Gregg
    Cc: Hemant Kumar
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20160615032840.31330.44412.stgit@devbox
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

14 Jun, 2016

2 commits

  • Uncomment and export synthesize_perf_probe_point() which had once
    introduced but has been disabled for a long time. This renews the code
    and re-enable it.

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Brendan Gregg
    Cc: Hemant Kumar
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20160608092949.3116.21958.stgit@devbox
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • Add perf_probe_event__copy() to copy perf_probe_event data structure and
    sub data structures under given source perf_probe_event.

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Brendan Gregg
    Cc: Hemant Kumar
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20160608092940.3116.18034.stgit@devbox
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

06 May, 2016

1 commit

  • ppc64le functions have a Global Entry Point (GEP) and a Local Entry
    Point (LEP). While placing a probe, we always prefer the LEP since it
    catches function calls through both the GEP and the LEP. In order to do
    this, we fixup the function entry points during elf symbol table lookup
    to point to the LEPs. This works, but breaks 'perf test kallsyms' since
    the symbols loaded from the symbol table (pointing to the LEP) do not
    match the symbols in kallsyms.

    To fix this, we do not adjust all the symbols during symbol table load.
    Instead, we note down st_other in a newly introduced arch-specific
    member of perf symbol structure, and later use this to adjust the probe
    trace point.

    Reported-by: Michael Ellerman
    Signed-off-by: Naveen N. Rao
    Acked-by: Ananth N Mavinakayanahalli
    Acked-by: Balbir Singh
    Cc: Mark Wielaard
    Cc: Masami Hiramatsu
    Cc: Thiago Jung Bauermann
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/6be7c2b17e370100c2f79dd444509df7929bdd3e.1460451721.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Naveen N. Rao
     

28 Apr, 2016

1 commit

  • Replace many fixed-length char array with strbuf to stringify
    perf_probe_event and probe_trace_event etc.

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: Hemant Kumar
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20160427183713.23446.97377.stgit@devbox
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

24 Mar, 2016

1 commit


15 Sep, 2015

1 commit

  • The init/exit_symbols_maps() functions are to setup and cleanup
    necessary info for probe events. But they need to be called from out of
    the probe code now, so this patch exports them.

    However the names are too generic, so change them to have 'probe'. :)

    Signed-off-by: Namhyung Kim
    Acked-by: Masami Hiramatsu
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1441852026-28974-2-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     

04 Sep, 2015

3 commits

  • Showing actual trace event when deleteing perf events is only needed in
    perf probe command. But the add functionality itself can be used by
    other places. So move the printing code into the cmd_probe().

    The output is not changed.

    Signed-off-by: Namhyung Kim
    Cc: Jiri Olsa
    Cc: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1441368963-11565-5-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • Showing actual trace event when adding perf events is only needed in
    perf probe command. But the add functionality itself can be used by
    other places. So move the printing code into the cmd_probe().

    Also it combines the output if more than one event is added.

    Before:
    $ sudo perf probe -a do_fork -a do_exit
    Added new event:
    probe:do_fork (on do_fork)

    You can now use it in all perf tools, such as:

    perf record -e probe:do_fork -aR sleep 1

    Added new events:
    probe:do_exit (on do_exit)
    probe:do_exit_1 (on do_exit)

    You can now use it in all perf tools, such as:

    perf record -e probe:do_exit_1 -aR sleep 1

    After:
    $ sudo perf probe -a do_fork -a do_exit
    Added new events:
    probe:do_fork (on do_fork)
    probe:do_exit (on do_exit)
    probe:do_exit_1 (on do_exit)

    You can now use it in all perf tools, such as:

    perf record -e probe:do_exit_1 -aR sleep 1

    Signed-off-by: Namhyung Kim
    Tested-by: Arnaldo Carvalho de Melo
    Acked-by: Masami Hiramatsu
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1441368963-11565-3-git-send-email-namhyung@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo

    Namhyung Kim
     
  • This patch drops struct __event_package structure. Instead, it adds a
    'struct trace_probe_event' pointer to 'struct perf_probe_event'.

    The trace_probe_event information gives further patches a chance to
    access actual probe points and actual arguments.

    Using them, 'perf probe' can get the whole list of added probes and
    print them at once.

    Other users like the upcoming bpf_loader will be able to attach one bpf
    program to different probing points of an inline function (which has
    multiple probing points) and glob functions.

    Moreover, by reading the arguments information, bpf code for reading
    those arguments can be generated.

    Signed-off-by: Wang Nan
    Acked-by: Masami Hiramatsu
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1441368963-11565-2-git-send-email-namhyung@kernel.org
    [namhyung: extract necessary part from the existing patch]
    Signed-off-by: Namhyung Kim
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     

26 Aug, 2015

1 commit

  • It should be useful to allow 'perf probe' probe at absolute offset of a
    target. For example, when (u)probing at a instruction of a shared object
    in a embedded system where debuginfo is not avaliable but we know the
    offset of that instruction by manually digging.

    This patch enables following perf probe command syntax:

    # perf probe 0xffffffff811e6615

    And

    # perf probe /lib/x86_64-linux-gnu/libc-2.19.so 0xeb860

    In the above example, we don't need a anchor symbol, so it is possible
    to compute absolute addresses using other methods and then use 'perf
    probe' to create the probing points.

    v1 -> v2:
    Drop the leading '+' in cmdline;
    Allow uprobing at offset 0x0;
    Improve 'perf probe -l' result when uprobe at area without debuginfo.

    v2 -> v3:
    Split bugfix to a separated patch.

    Test result:

    # perf probe 0xffffffff8119d175 %ax
    # perf probe sys_write %ax
    # perf probe /lib64/libc-2.18.so 0x0 %ax
    # perf probe /lib64/libc-2.18.so 0x5 %ax
    # perf probe /lib64/libc-2.18.so 0xd8e40 %ax
    # perf probe /lib64/libc-2.18.so __write %ax
    # perf probe /lib64/libc-2.18.so 0xd8e49 %ax
    # cat /sys/kernel/debug/tracing/uprobe_events

    p:probe_libc/abs_0 /lib64/libc-2.18.so:0x (null) arg1=%ax
    p:probe_libc/abs_5 /lib64/libc-2.18.so:0x0000000000000005 arg1=%ax
    p:probe_libc/abs_d8e40 /lib64/libc-2.18.so:0x00000000000d8e40 arg1=%ax
    p:probe_libc/__write /lib64/libc-2.18.so:0x00000000000d8e40 arg1=%ax
    p:probe_libc/abs_d8e49 /lib64/libc-2.18.so:0x00000000000d8e49 arg1=%ax

    # cat /sys/kernel/debug/tracing/kprobe_events

    p:probe/abs_ffffffff8119d175 0xffffffff8119d175 arg1=%ax
    p:probe/sys_write _text+1692016 arg1=%ax

    # perf probe -l

    Failed to find debug information for address 5
    probe:abs_ffffffff8119d175 (on sys_write+5 with arg1)
    probe:sys_write (on sys_write with arg1)
    probe_libc:__write (on @unix/syscall-template.S:81 in /lib64/libc-2.18.so with arg1)
    probe_libc:abs_0 (on 0x0 in /lib64/libc-2.18.so with arg1)
    probe_libc:abs_5 (on 0x5 in /lib64/libc-2.18.so with arg1)
    probe_libc:abs_d8e40 (on @unix/syscall-template.S:81 in /lib64/libc-2.18.so with arg1)
    probe_libc:abs_d8e49 (on __GI___libc_write+9 in /lib64/libc-2.18.so with arg1)

    Signed-off-by: Wang Nan
    Acked-by: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Steven Rostedt
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Link: http://lkml.kernel.org/r/1440586666-235233-7-git-send-email-wangnan0@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     

07 Aug, 2015

1 commit

  • Commit 7b6ff0bdbf4f7f429c2116cca92a6d171217449e ("perf probe ppc64le:
    Fixup function entry if using kallsyms lookup") adds 'struct map' into
    probe-event.h but not forward declares it. This patch fixes it.

    Signed-off-by: Wang Nan
    Cc: Alexei Starovoitov
    Cc: Brendan Gregg
    Cc: Daniel Borkmann
    Cc: David Ahern
    Cc: He Kuang
    Cc: Jiri Olsa
    Cc: Kaixu Xia
    Cc: Masami Hiramatsu
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Zefan Li
    Cc: pi3orama@163.com
    Fixes: 7b6ff0bdbf4f ("perf probe ppc64le: Fixup function entry if using kallsyms lookup")
    Link: http://lkml.kernel.org/n/1436445342-1402-30-git-send-email-wangnan0@huawei.com
    [ No need to include map.h, just forward declare 'struct map' ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Wang Nan
     

21 Jul, 2015

1 commit

  • Move ftrace probe-event operations to probe-file.c from probe-event.c.

    Signed-off-by: Masami Hiramatsu
    Cc: Adrian Hunter
    Cc: Borislav Petkov
    Cc: Hemant Kumar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20150715091407.8915.14316.stgit@localhost.localdomain
    [ Fixed up strlist__new() calls wrt 4a77e2183fc0 ("perf strlist: Make dupstr be the...") ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

27 May, 2015

1 commit

  • Show the reason of error when dso__load* fails. This shows when user
    gives wrong kernel image or wrong path.

    Without this, perf probe shows an obscure message:

    ----
    $ perf probe -k ~/kbin/linux-3.x86_64/vmlinux -L vfs_read
    Failed to find path of kernel module.
    Error: Failed to show lines.
    ----

    With this, perf shows appropriate error message:

    ----
    $ perf probe -k ~/kbin/linux-3.x86_64/vmlinux -L vfs_read
    Failed to find the path for kernel: Mismatching build id
    Error: Failed to show lines.
    ----

    And:

    ----
    $ perf probe -k /non-exist/kernel/vmlinux -L vfs_read
    Failed to find the path for kernel: No such file or directory
    Error: Failed to show lines.
    ----

    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Richard Weinberger
    Link: http://lkml.kernel.org/r/20150527083718.23880.84100.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

12 May, 2015

1 commit

  • It is not easy for users to get the accurate byte offset or the line
    number where a local variable can be probed.

    With '--range' option, local variables in the scope of the probe point
    are showed with a byte offset range, and can be added according to this
    range information.

    For example, there are some variables in the function
    generic_perform_write():


    0 ssize_t generic_perform_write(struct file *file,
    1 struct iov_iter *i, loff_t pos)
    2 {
    3 struct address_space *mapping = file->f_mapping;
    4 const struct address_space_operations *a_ops = mapping->a_ops;
    ...
    42 status = a_ops->write_begin(file, mapping, pos, bytes, flags,
    &page, &fsdata);
    44 if (unlikely(status < 0))

    But we fail when we try to probe the variable 'a_ops' at line 42 or 44.

    $ perf probe --add 'generic_perform_write:42 a_ops'
    Failed to find the location of a_ops at this address.
    Perhaps, it has been optimized out.

    This is because the source code do not match the assembly, so a variable
    may not be available in the source code line where it appears.

    After this patch, we can lookup the accurate byte offset range of a
    variable, 'INV' indicates that this variable is not valid at the given
    point, but available in the scope:

    $ perf probe --vars 'generic_perform_write:42' --range
    Available variables at generic_perform_write:42
    @
    [INV] ssize_t written @
    [INV] struct address_space_operations* a_ops @
    [VAL] (unknown_type) fsdata @
    [VAL] loff_t pos @
    [VAL] long int status @
    [VAL] long unsigned int bytes @
    [VAL] struct address_space* mapping @
    [VAL] struct iov_iter* i @
    [VAL] struct page* page @

    Then it is more clear for us to add a probe with this variable:

    $ perf probe --add 'generic_perform_write+170 a_ops'
    Added new event:
    probe:generic_perform_write (on generic_perform_write+170 with a_ops)

    Signed-off-by: He Kuang
    Acked-by: Masami Hiramatsu
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Wang Nan
    Link: http://lkml.kernel.org/r/1431336304-16863-2-git-send-email-hekuang@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo

    He Kuang
     

09 May, 2015

4 commits

  • Support glob wildcards for function name when adding new probes. This
    will allow us to build caches of function-entry level information with
    $params.

    e.g.
    ----
    # perf probe --no-inlines --add 'kmalloc* $params'
    Added new events:
    probe:kmalloc_slab (on kmalloc* with $params)
    probe:kmalloc_large_node (on kmalloc* with $params)
    probe:kmalloc_order_trace (on kmalloc* with $params)

    You can now use it in all perf tools, such as:

    perf record -e probe:kmalloc_order_trace -aR sleep 1

    # perf probe --list
    probe:kmalloc_large_node (on kmalloc_large_node@mm/slub.c with size flags node)
    probe:kmalloc_order_trace (on kmalloc_order_trace@mm/slub.c with size flags order)
    probe:kmalloc_slab (on kmalloc_slab@mm/slab_common.c with size flags)
    ----

    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Ananth N Mavinakayanahalli
    Cc: David Ahern
    Cc: Hemant Kumar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20150508010335.24812.19972.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • Add --no-inlines(--inlines) option to avoid searching inline functions.

    Searching all functions which matches glob pattern can take a long time
    and find a lot of inline functions.

    With this option perf-probe searches target on the non-inlined
    functions.

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: David Ahern
    Cc: Hemant Kumar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20150508010333.24812.86568.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • Introduce probe_conf global configuration parameters for probe-event and
    probe-finder, and removes related parameters from APIs.

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: David Ahern
    Cc: Hemant Kumar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20150508010330.24812.21095.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • Use perf_probe_event.target field for the target binary instead of
    passing it as an argument.

    Signed-off-by: Masami Hiramatsu
    Cc: Ananth N Mavinakayanahalli
    Cc: David Ahern
    Cc: Hemant Kumar
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20150508010328.24812.67887.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

06 May, 2015

1 commit

  • This makes perf-probe --del option to accept filter rules
    not only simple glob pattern. This simplifies the code and
    improve the flexibility.

    E.g. if we remove 2 different pattern events, we need 2
    -d options.
    ----
    # ./perf probe -d vfs\* -d malloc
    Removed event: probe_libc:malloc
    Removed event: probe:vfs_read
    ----

    This allows you to joint the 2 patterns with '|'.

    ----
    # ./perf probe -d 'vfs*|malloc'
    Removed event: probe:vfs_read
    Removed event: probe_libc:malloc
    ----

    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20150505022948.23399.4197.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

04 May, 2015

3 commits

  • Currently, perf-probe --list option ignores given event filter.
    ----
    # ./perf probe -l vfs\*
    probe:vfs_read (on vfs_read@ksrc/linux-3/fs/read_write.c)
    probe_libc:malloc (on __libc_malloc@malloc/malloc.c in /usr/lib64/libc-2.17.so)
    ----

    This changes --list option to accept the event filter argument as below.
    ----
    # ./perf probe -l vfs\*
    probe:vfs_read (on vfs_read@ksrc/linux-3/fs/read_write.c)
    # ./perf probe -l \*libc:\*
    probe_libc:malloc (on __libc_malloc@malloc/malloc.c in /usr/lib64/libc-2.17.so)
    ----

    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20150424094750.23967.53868.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • On powerpc ABIv2, if no debug-info is found and we use kallsyms, we need
    to fixup the function entry to point to the local entry point. Use
    offset of 8 since current toolchains always generate 2 instructions (8
    bytes).

    Signed-off-by: Naveen N. Rao
    Reviewed-by: Srikar Dronamraju
    Cc: Ananth N Mavinakayanahalli
    Cc: Masami Hiramatsu
    Cc: Michael Ellerman
    Cc: Sukadev Bhattiprolu
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/92253021e77a104b23b615c8c23bf9501dfe60bf.1430217967.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Naveen N. Rao
     
  • Use symbol table lookups by default if DWARF is not necessary, since
    powerpc ABIv2 encodes local entry points in the symbol table and the
    function entry address in DWARF may not be appropriate for kprobes, as
    described here:

    https://sourceware.org/bugzilla/show_bug.cgi?id=17638

    "The DWARF address ranges deliberately include the *whole* function,
    both global and local entry points."
    ...
    "If you want to set probes on a local entry point, you should look up
    the symbol in the main symbol table (not DWARF), and check the st_other
    bits; they will indicate whether the function has a local entry point,
    and what its offset from the global entry point is. Note that GDB does
    the same when setting a breakpoint on a function entry."

    Signed-off-by: Naveen N. Rao
    Reviewed-by: Srikar Dronamraju
    Cc: Ananth N Mavinakayanahalli
    Cc: Masami Hiramatsu
    Cc: Michael Ellerman
    Cc: Sukadev Bhattiprolu
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: http://lkml.kernel.org/r/88a10e22f4aaba2aef812824ca4b10d7beeea012.1430217967.git.naveen.n.rao@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Naveen N. Rao
     

10 Apr, 2015

1 commit

  • Support multiple probes on different binaries with just
    one command.

    In the result, this example sets up the probes on icmp_rcv in
    kernel, on main and set_target in perf, and on pcspkr_event
    in pcspker.ko driver.
    -----
    # perf probe -a icmp_rcv -x ./perf -a main -a set_target \
    -m /lib/modules/4.0.0-rc5+/kernel/drivers/input/misc/pcspkr.ko \
    -a pcspkr_event
    Added new event:
    probe:icmp_rcv (on icmp_rcv)

    You can now use it in all perf tools, such as:

    perf record -e probe:icmp_rcv -aR sleep 1

    Added new event:
    probe_perf:main (on main in /home/mhiramat/ksrc/linux-3/tools/perf/perf)

    You can now use it in all perf tools, such as:

    perf record -e probe_perf:main -aR sleep 1

    Added new event:
    probe_perf:set_target (on set_target in /home/mhiramat/ksrc/linux-3/tools/perf/perf)

    You can now use it in all perf tools, such as:

    perf record -e probe_perf:set_target -aR sleep 1

    Added new event:
    probe:pcspkr_event (on pcspkr_event in pcspkr)

    You can now use it in all perf tools, such as:

    perf record -e probe:pcspkr_event -aR sleep 1
    -----

    Reported-by: Arnaldo Carvalho de Melo
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: David Ahern
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20150401102539.17137.46454.stgit@localhost.localdomain
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

18 Sep, 2014

1 commit

  • 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
    @
    (No matched variables)
    @
    (No matched variables)
    @
    char* name
    size_t len
    struct cmdnames* cmds
    $ perf probe -x ./perf -L add_cmdname

    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: Masami Hiramatsu
    Cc: david lerner
    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: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

18 Feb, 2014

1 commit

  • Replace line_list (struct line_node) with intlist for reducing similar
    codes.

    Signed-off-by: Masami Hiramatsu
    Acked-by: Namhyung Kim
    Cc: David Ahern
    Cc: "David A. Long"
    Cc: Ingo Molnar
    Cc: Namhyung Kim
    Cc: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: Steven Rostedt
    Cc: yrl.pp-manager.tt@hitachi.com
    Link: http://lkml.kernel.org/r/20140206053209.29635.81043.stgit@kbuild-fedora.yrl.intra.hitachi.co.jp
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

17 Jan, 2014

1 commit

  • To fix a memory leak, release all dynamically allocated
    options/parameters in params data structure. This also
    introduces/exports some init/clear routines.

    Reported-by: David Ahern
    Signed-off-by: Masami Hiramatsu
    Cc: "David A. Long"
    Cc: "Steven Rostedt (Red Hat)"
    Cc: David Ahern
    Cc: Ingo Molnar
    Cc: Namhyung Kim
    Cc: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: yrl.pp-manager.tt@hitachi.com
    Link: http://lkml.kernel.org/r/20140116093947.24403.80118.stgit@kbuild-fedora.novalocal
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

26 Dec, 2013

1 commit

  • 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

    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
    @
    char* name
    struct map* map
    symbol_filter_t filter
    @
    char* name
    symbol_filter_t filter
    @
    char* name
    symbol_filter_t filter
    @
    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: Masami Hiramatsu
    Cc: David Ahern
    Cc: David A. Long
    Cc: Ingo Molnar
    Cc: Namhyung Kim
    Cc: Oleg Nesterov
    Cc: Srikar Dronamraju
    Cc: Steven Rostedt
    Cc: systemtap@sourceware.org
    Cc: yrl.pp-manager.tt@hitachi.com
    Link: http://lkml.kernel.org/r/20131226054152.22364.47021.stgit@kbuild-fedora.novalocal
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

12 May, 2012

1 commit

  • - Enhances perf to probe user space executables and libraries.
    - Enhances -F/--funcs option of "perf probe" to list possible probe points in
    an executable file or library.
    - Documents userspace probing support in perf.

    [ Probing a function in the executable using function name ]
    perf probe -x /bin/zsh zfree

    [ Probing a library function using function name ]
    perf probe -x /lib64/libc.so.6 malloc

    [ list probe-able functions in an executable ]
    perf probe -F -x /bin/zsh

    [ list probe-able functions in an library]
    perf probe -F -x /lib/libc.so.6

    Signed-off-by: Srikar Dronamraju
    Cc: Ananth N Mavinakayanahalli
    Cc: Andi Kleen
    Cc: Andrew Morton
    Cc: Anton Arapov
    Cc: Christoph Hellwig
    Cc: Ingo Molnar
    Cc: Jim Keniston
    Cc: Linus Torvalds
    Cc: Linux-mm
    Cc: Masami Hiramatsu
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Steven Rostedt
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20120416120909.30661.99781.sendpatchset@srdronam.in.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo

    Srikar Dronamraju
     

16 Jul, 2011

1 commit

  • Add probed module name and ":" in front of function name
    if -m module option is given. In the result, the symbol
    name passed to kprobe-tracer becomes MODULE:FUNCTION,
    so that kallsyms can solve it as a symbol in the module
    correctly.

    Signed-off-by: Masami Hiramatsu
    Cc: Peter Zijlstra
    Cc: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: Ingo Molnar
    Cc: Arnaldo Carvalho de Melo
    Link: http://lkml.kernel.org/r/20110627072745.6528.26416.stgit@fedora15
    Signed-off-by: Steven Rostedt

    Masami Hiramatsu
     

28 Jan, 2011

2 commits

  • Add filters support for available function list.

    Default filter is "!_*" for filtering out local-purpose symbols.

    e.g.:
    # perf probe --filter="add*" -F
    add_disk
    add_disk_randomness
    add_input_randomness
    add_interrupt_randomness
    add_memory
    add_page_to_unevictable_list
    add_page_wait_queue
    ...

    Cc: 2nddept-manager@sdl.hitachi.co.jp
    Cc: Chase Douglas
    Cc: Franck Bui-Huu
    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Srikar Dronamraju
    Cc: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     
  • Add filters support for available variable list.

    Default filter is "!__k???tab_*&!__crc_*" for filtering out
    automatically generated symbols.

    The format of filter rule is "[!]GLOBPATTERN", so you can use wild
    cards. If the filter rule starts with '!', matched variables are filter
    out.

    e.g.:
    # perf probe -V schedule --externs --filter=cpu*
    Available variables at schedule
    @
    cpumask_var_t cpu_callout_mask
    cpumask_var_t cpu_core_map
    cpumask_var_t cpu_isolated_map
    cpumask_var_t cpu_sibling_map
    int cpu_number
    long unsigned int* cpu_bit_bitmap
    ...

    Cc: 2nddept-manager@sdl.hitachi.co.jp
    Cc: Chase Douglas
    Cc: Franck Bui-Huu
    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Srikar Dronamraju
    Cc: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Masami Hiramatsu
    [ committer note: Removed the elf.h include as it was fixed up in e80711c]
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

24 Jan, 2011

1 commit

  • Add --funcs to show available functions in symtab.

    Originally this feature came from Srikar's uprobes patches
    ( http://lkml.org/lkml/2010/8/27/244 )

    e.g.
    ...
    __ablkcipher_walk_complete
    __absent_pages_in_range
    __account_scheduler_latency
    __add_pages
    __alloc_pages_nodemask
    __alloc_percpu
    __alloc_reserved_percpu
    __alloc_skb
    __alloc_workqueue_key
    __any_online_cpu
    __ata_ehi_push_desc
    ...

    This also supports symbols in module, e.g.

    ...
    cleanup_module
    cpuid_maxphyaddr
    emulate_clts
    emulate_instruction
    emulate_int_real
    emulate_invlpg
    emulator_get_dr
    emulator_set_dr
    emulator_task_switch
    emulator_write_emulated
    emulator_write_phys
    fx_init
    ...

    Original-patch-from: Srikar Dronamraju
    Cc: 2nddept-manager@sdl.hitachi.co.jp
    Cc: Franck Bui-Huu
    Cc: Ingo Molnar
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Srikar Dronamraju
    Cc: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Masami Hiramatsu
    [ committer note: Add missing elf.h for STB_GLOBAL that broke a RHEL4 build ]
    Signed-off-by: Arnaldo Carvalho de Melo

    Masami Hiramatsu
     

22 Oct, 2010

1 commit

  • Add basic module probe support on perf probe. This introduces "--module
    " option to perf probe for putting probes and showing lines and
    variables in the given module.

    Currently, this supports only probing on running modules. Supporting off-line
    module probing is the next step.

    e.g.)
    [show lines]
    # ./perf probe --module drm -L drm_vblank_info

    0 int drm_vblank_info(struct seq_file *m, void *data)
    1 {
    struct drm_info_node *node = (struct drm_info_node *) m->private
    3 struct drm_device *dev = node->minor->dev;
    ...
    [show vars]
    # ./perf probe --module drm -V drm_vblank_info:3
    Available variables at drm_vblank_info:3
    @
    (unknown_type) data
    struct drm_info_node* node
    struct seq_file* m
    [put a probe]
    # ./perf probe --module drm drm_vblank_info:3 node m
    Add new event:
    probe:drm_vblank_info (on drm_vblank_info:3 with node m)

    You can now use it on all perf tools, such as:

    perf record -e probe:drm_vblank_info -aR sleep 1
    [list probes]
    # ./perf probe -l
    probe:drm_vblank_info (on drm_vblank_info:3@drivers/gpu/drm/drm_info.c with ...

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

    Masami Hiramatsu