• Arnaldo Carvalho de Melo's avatar
    perf symbols: Accept symbols starting at address 0 · b843f62a
    Arnaldo Carvalho de Melo authored
    That is the case of _text on s390, and we have some functions that return an
    address, using address zero to report problems, oops.
    
    This would lead the symbol loading routines to not use "_text" as the reference
    relocation symbol, or the first symbol for the kernel, but use instead
    "_stext", that is at the same address on x86_64 and others, but not on s390:
    
      [acme@localhost perf-4.11.0-rc6]$ head -15 /proc/kallsyms
      0000000000000000 T _text
      0000000000000418 t iplstart
      0000000000000800 T start
      000000000000080a t .base
      000000000000082e t .sk8x8
      0000000000000834 t .gotr
      0000000000000842 t .cmd
      0000000000000846 t .parm
      000000000000084a t .lowcase
      0000000000010000 T startup
      0000000000010010 T startup_kdump
      0000000000010214 t startup_kdump_relocated
      0000000000011000 T startup_continue
      00000000000112a0 T _ehead
      0000000000100000 T _stext
      [acme@localhost perf-4.11.0-rc6]$
    
    Which in turn would make 'perf test vmlinux' to fail because it wouldn't find
    the symbols before "_stext" in kallsyms.
    
    Fix it by using the return value only for errors and storing the
    address, when the symbol is successfully found, in a provided pointer
    arg.
    
    Before this patch:
    
    After:
    
      [acme@localhost perf-4.11.0-rc6]$ tools/perf/perf test -v 1
       1: vmlinux symtab matches kallsyms            :
      --- start ---
      test child forked, pid 40693
      Looking at the vmlinux_path (8 entries long)
      Using /usr/lib/debug/lib/modules/3.10.0-654.el7.s390x/vmlinux for symbols
      ERR : 0: _text not on kallsyms
      ERR : 0x418: iplstart not on kallsyms
      ERR : 0x800: start not on kallsyms
      ERR : 0x80a: .base not on kallsyms
      ERR : 0x82e: .sk8x8 not on kallsyms
      ERR : 0x834: .gotr not on kallsyms
      ERR : 0x842: .cmd not on kallsyms
      ERR : 0x846: .parm not on kallsyms
      ERR : 0x84a: .lowcase not on kallsyms
      ERR : 0x10000: startup not on kallsyms
      ERR : 0x10010: startup_kdump not on kallsyms
      ERR : 0x10214: startup_kdump_relocated not on kallsyms
      ERR : 0x11000: startup_continue not on kallsyms
      ERR : 0x112a0: _ehead not on kallsyms
      <SNIP warnings>
      test child finished with -1
      ---- end ----
      vmlinux symtab matches kallsyms: FAILED!
      [acme@localhost perf-4.11.0-rc6]$
    
    After:
    
      [acme@localhost perf-4.11.0-rc6]$ tools/perf/perf test -v 1
       1: vmlinux symtab matches kallsyms            :
      --- start ---
      test child forked, pid 47160
      <SNIP warnings>
      test child finished with 0
      ---- end ----
      vmlinux symtab matches kallsyms: Ok
      [acme@localhost perf-4.11.0-rc6]$
    Reported-by: default avatarMichael Petlan <mpetlan@redhat.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: David Ahern <dsahern@gmail.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: http://lkml.kernel.org/n/tip-9x9bwgd3btwdk1u51xie93fz@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    b843f62a
event.h 16.4 KB