1. 08 4月, 2016 1 次提交
    • W
      perf symbols: Record text offset in dso to calculate objdump address · a58f7033
      Wang Nan 提交于
      In this patch, the offset of '.text' section is stored into dso
      and used here to re-calculate address to objdump.
      
      In most of the cases, executable code is in '.text' section, so the
      adjustment made to a symbol in dso__load_sym (using
      sym.st_value -= shdr.sh_addr - shdr.sh_offset) should equal to
      'sym.st_value -= dso->text_offset'. Therefore, adding text_offset back
      get objdump address from symbol address (rip). However, it is not true
      for kernel and kernel module since there could be multiple executable
      sections with different offset. Exclude kernel for this reason.
      
      After this patch, even dso->adjust_symbols is set to true for shared
      objects, map__rip_2objdump() and map__objdump_2mem() would return
      correct result, so perf behavior of annotate won't be changed.
      Signed-off-by: NWang Nan <wangnan0@huawei.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Cody P Schafer <dev@codyps.com>
      Cc: He Kuang <hekuang@huawei.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kirill Smelkov <kirr@nexedi.com>
      Cc: Li Zefan <lizefan@huawei.com>
      Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Zefan Li <lizefan@huawei.com>
      Cc: pi3orama@163.com
      Link: http://lkml.kernel.org/r/1460024671-64774-2-git-send-email-wangnan0@huawei.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a58f7033
  2. 10 12月, 2015 2 次提交
    • M
      perf tools: Fix maps__fixup_overlappings to put used maps · d91130e9
      Masami Hiramatsu 提交于
      Since the __map_groups__insert got the given map, we don't need to keep
      it. So put the maps.
      
      Refcnt debugger shows that map_groups__fixup_overlappings() got a map
      twice but the group released it just once. This pattern usually
      indicates the leak happens in caller site.
      
        ----
        ==== [0] ====
        Unreclaimed map@0x39d3ae0
        Refcount +1 => 1 at
          ./perf(map_groups__fixup_overlappings+0x335) [0x4c1865]
          ./perf(thread__insert_map+0x30) [0x4c8e00]
          ./perf(machine__process_mmap2_event+0x106) [0x4bd876]
          ./perf() [0x4c378e]
          ./perf() [0x4c4393]
          ./perf(perf_session__process_events+0x38a) [0x4c654a]
          ./perf(cmd_record+0xe24) [0x42fc94]
          ./perf() [0x47b745]
          ./perf(main+0x617) [0x422547]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2eca2deaf5]
          ./perf() [0x4226bd]
        Refcount +1 => 2 at
          ./perf(map_groups__fixup_overlappings+0x3c5) [0x4c18f5]
          ./perf(thread__insert_map+0x30) [0x4c8e00]
          ./perf(machine__process_mmap2_event+0x106) [0x4bd876]
          ./perf() [0x4c378e]
          ./perf() [0x4c4393]
          ./perf(perf_session__process_events+0x38a) [0x4c654a]
          ./perf(cmd_record+0xe24) [0x42fc94]
          ./perf() [0x47b745]
          ./perf(main+0x617) [0x422547]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2eca2deaf5]
          ./perf() [0x4226bd]
        Refcount -1 => 1 at
          ./perf(map_groups__exit+0x92) [0x4c0962]
          ./perf(map_groups__put+0x60) [0x4c0bc0]
          ./perf(thread__put+0x90) [0x4c8a40]
          ./perf(machine__delete_threads+0x7e) [0x4bad9e]
          ./perf(perf_session__delete+0x4f) [0x4c499f]
          ./perf(cmd_record+0xb6d) [0x42f9dd]
          ./perf() [0x47b745]
          ./perf(main+0x617) [0x422547]
          /lib64/libc.so.6(__libc_start_main+0xf5) [0x7f2eca2deaf5]
          ./perf() [0x4226bd]
        ----
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20151209021131.10245.41485.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d91130e9
    • M
      perf tools: Fix map_groups__clone to put cloned map · bae32b50
      Masami Hiramatsu 提交于
      Fix map_groups__clone to put cloned map after inserting it to the
      map_groups.
      
      Refcnt debugger shows:
        ----
        ==== [0] ====
        Unreclaimed map: 0x2a27ee0
        Refcount +1 => 1 at
          ./perf(map_groups__clone+0x8d) [0x4bb7ed]
          ./perf(thread__fork+0xbe) [0x4c1f9e]
          ./perf(machine__process_fork_event+0x216) [0x4b79a6]
          ./perf(perf_event__synthesize_threads+0x38b) [0x48135b]
          ./perf(cmd_top+0xdc6) [0x43cb76]
          ./perf() [0x477223]
          ./perf(main+0x617) [0x422077]
          /lib64/libc.so.6(__libc_start_main+0xf0) [0x7ff806af8fe0]
          ./perf() [0x4221ed]
        Refcount +1 => 2 at
          ./perf(map_groups__clone+0x128) [0x4bb888]
          ./perf(thread__fork+0xbe) [0x4c1f9e]
          ./perf(machine__process_fork_event+0x216) [0x4b79a6]
          ./perf(perf_event__synthesize_threads+0x38b) [0x48135b]
          ./perf(cmd_top+0xdc6) [0x43cb76]
          ./perf() [0x477223]
          ./perf(main+0x617) [0x422077]
          /lib64/libc.so.6(__libc_start_main+0xf0) [0x7ff806af8fe0]
          ./perf() [0x4221ed]
        Refcount -1 => 1 at
          ./perf(map_groups__exit+0x87) [0x4ba757]
          ./perf(map_groups__put+0x68) [0x4ba9a8]
          ./perf(thread__put+0x8b) [0x4c1aeb]
          ./perf(machine__delete_threads+0x81) [0x4b48f1]
          ./perf(perf_session__delete+0x4f) [0x4be63f]
          ./perf(cmd_top+0x1094) [0x43ce44]
          ./perf() [0x477223]
          ./perf(main+0x617) [0x422077]
          /lib64/libc.so.6(__libc_start_main+0xf0) [0x7ff806af8fe0]
          ./perf() [0x4221ed]
        ----
      
      This shows map_groups__clone get the map twice and put it when
      map_groups__exit.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Link: http://lkml.kernel.org/r/20151209021120.10245.95388.stgit@localhost.localdomainSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bae32b50
  3. 27 11月, 2015 1 次提交
  4. 05 11月, 2015 1 次提交
    • J
      perf tools: Insert split maps correctly into origin group · cb8382e0
      Jiri Olsa 提交于
      When new maps are cloned out of split map they are added into origin
      map's group, but their groups pointer is not updated.
      
      This could lead to a segfault, because map->groups is expected to be
      always set as reported by Markus:
      
        __map__is_kernel (map=map@entry=0x1abb7a0) at util/map.c:238
        238             return __machine__kernel_map(map->groups->machine, map->type) =
        (gdb) bt
        #0  __map__is_kernel (map=map@entry=0x1abb7a0) at util/map.c:238
        #1  0x00000000004393e4 in symbol_filter (map=map@entry=0x1abb7a0, sym=sym@entry
        #2  0x00000000004fcd4d in dso__load_sym (dso=dso@entry=0x166dae0, map=map@entry
        #3  0x00000000004a64e0 in dso__load (dso=0x166dae0, map=map@entry=0x1abb7a0, fi
        #4  0x00000000004b941f in map__load (filter=0x4393c0 <symbol_filter>, map=<opti
        #5  map__find_symbol (map=0x1abb7a0, addr=40188, filter=0x4393c0 <symbol_filter
        ...
      
      Adding __map_groups__insert function to add map into groups together
      with map->groups pointer update. It takes no lock as opposed to existing
      map_groups__insert, as maps__fixup_overlappings(), where it is being
      called, already has the necessary lock held.
      
      Using __map_groups__insert to add new maps after map split.
      Reported-by: NMarkus Trippelsdorf <markus@trippelsdorf.de>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NMarkus Trippelsdorf <markus@trippelsdorf.de>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20151104140811.GA32664@krava.brq.redhat.com
      Fixes: cfc5acd4 ("perf top: Filter symbols based on __map__is_kernel(map)")
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cb8382e0
  5. 01 10月, 2015 3 次提交
  6. 21 8月, 2015 1 次提交
  7. 23 7月, 2015 1 次提交
  8. 16 6月, 2015 1 次提交
  9. 08 6月, 2015 1 次提交
    • A
      perf tools: Reference count struct dso · d3a7c489
      Arnaldo Carvalho de Melo 提交于
      This has a different model than the 'thread' and 'map' struct lifetimes:
      there is not a definitive "don't use this DSO anymore" event, i.e. we may
      get many 'struct map' holding references to the '/usr/lib64/libc-2.20.so'
      DSO but then at some point some DSO may have no references but we still
      don't want to straight away release its resources, because "soon" we may
      get a new 'struct map' that needs it and we want to reuse its symtab or
      other resources.
      
      So we need some way to garbage collect it when crossing some memory
      usage threshold, which is left for anoter patch, for now it is
      sufficient to release it when calling dsos__exit(), i.e. when deleting
      the whole list as part of deleting the 'struct machine' containing it,
      which will leave only referenced objects being used.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/n/tip-majzgz07cm90t2tejrjy4clf@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d3a7c489
  10. 29 5月, 2015 3 次提交
  11. 28 5月, 2015 4 次提交
  12. 27 5月, 2015 3 次提交
  13. 16 5月, 2015 1 次提交
  14. 04 5月, 2015 1 次提交
  15. 08 4月, 2015 1 次提交
  16. 25 11月, 2014 1 次提交
  17. 29 10月, 2014 1 次提交
    • A
      perf tools: Set thread->mg.machine in all places · 11246c70
      Arnaldo Carvalho de Melo 提交于
      We were setting this only in machine__init(), i.e. for the map_groups that
      holds the kernel module maps, not for the one used for a thread's executable
      mmaps.
      
      Now we are sure that we can obtain the machine where a thread is by going
      via thread->mg->machine, thus we can, in the following patch, make all
      codepaths that receive machine _and_ thread, drop the machine one.
      
      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: Jean Pihet <jean.pihet@linaro.org>
      Cc: Jiri Olsa <jolsa@redhat.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-y6zgaqsvhrf04v57u15e4ybm@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      11246c70
  18. 15 10月, 2014 2 次提交
  19. 20 8月, 2014 1 次提交
  20. 24 7月, 2014 2 次提交
  21. 17 7月, 2014 2 次提交
  22. 09 6月, 2014 1 次提交
  23. 21 5月, 2014 1 次提交
  24. 28 4月, 2014 2 次提交
  25. 01 2月, 2014 1 次提交
  26. 24 1月, 2014 1 次提交
    • M
      perf symbols: Load map before using map->map_ip() · 4afc81cd
      Masami Hiramatsu 提交于
      In map_groups__find_symbol() map->map_ip is used without ensuring the
      map is loaded. Then the address passed to map->map_ip isn't mapped at
      the first time.
      
      E.g. below code always fails to get a symbol at the first call;
      
      	addr = /* Somewhere in the kernel text */
      	symbol_conf.try_vmlinux_path = true;
      	symbol__init();
      	host_machine = machine__new_host();
      	sym = machine__find_kernel_function(host_machine,
      					 addr, NULL, NULL);
      	/* Note that machine__find_kernel_function calls
      	   map_groups__find_symbol */
      
      This ensures it by calling map__load before using it in
      map_groups__find_symbol().
      Signed-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 (Red Hat)" <rostedt@goodmis.org>
      Cc: yrl.pp-manager.tt@hitachi.com
      Link: http://lkml.kernel.org/r/20140123022950.7206.17357.stgit@kbuild-fedora.yrl.intra.hitachi.co.jpSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4afc81cd