• Ravi Bangoria's avatar
    perf probe ppc64le: Fix probe location when using DWARF · 99e608b5
    Ravi Bangoria authored
    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: default avatarRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
    Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
    Cc: Balbir Singh <bsingharora@gmail.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/r/1470723805-5081-2-git-send-email-ravi.bangoria@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    99e608b5
sym-handling.c 2.91 KB