linux/tools
Arnaldo Carvalho de Melo 1ae14516cb perf map_groups: Add a front end cache for map lookups by name
Lets see if it helps:

First look at the probeable lines for the function that does lookups by
name in a map_groups struct:

  # perf probe -x ~/bin/perf -L map_groups__find_by_name
  <map_groups__find_by_name@/home/acme/git/perf/tools/perf/util/symbol.c:0>
        0  struct map *map_groups__find_by_name(struct map_groups *mg, const char *name)
        1  {
        2         struct maps *maps = &mg->maps;
                  struct map *map;

        5         down_read(&maps->lock);

        7         if (mg->last_search_by_name && strcmp(mg->last_search_by_name->dso->short_name, name) == 0) {
        8                 map = mg->last_search_by_name;
        9                 goto out_unlock;
                  }

       12         maps__for_each_entry(maps, map)
       13                 if (strcmp(map->dso->short_name, name) == 0) {
       14                         mg->last_search_by_name = map;
       15                         goto out_unlock;
                          }

       18         map = NULL;

           out_unlock:
       21         up_read(&maps->lock);
       22         return map;
       23  }

           int dso__load_vmlinux(struct dso *dso, struct map *map,
                                const char *vmlinux, bool vmlinux_allocated)

  #

Now add a probe to the place where we reuse the last search:

  # perf probe -x ~/bin/perf map_groups__find_by_name:8
  Added new event:
    probe_perf:map_groups__find_by_name (on map_groups__find_by_name:8 in /home/acme/bin/perf)

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

  	perf record -e probe_perf:map_groups__find_by_name -aR sleep 1

  #

Now lets do a system wide 'perf stat' counting those events:

  # perf stat -e probe_perf:*

Leave it running and lets do a 'perf top', then, after a while, stop the
'perf stat':

  # perf stat -e probe_perf:*
  ^C
   Performance counter stats for 'system wide':

               3,603      probe_perf:map_groups__find_by_name

        44.565253139 seconds time elapsed
  #

yeah, good to have.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-tcz37g3nxv3tvxw3q90vga3p@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-11-18 11:21:32 -03:00
..
accounting
arch perf/core improvements and fixes: 2019-10-22 01:15:45 +02:00
bpf tools: bpf: Use !building_out_of_srctree to determine srctree 2019-09-30 10:53:34 +02:00
build
cgroup iocost_monitor: Report debt 2019-09-10 12:31:39 -06:00
debugging
firewire
firmware
gpio tools: gpio: Use !building_out_of_srctree to determine srctree 2019-10-22 14:42:42 +02:00
hv - First round of vmbus hibernation support from Dexuan Cui. 2019-09-24 12:36:31 -07:00
iio
include tools headers UAPI: Sync sched.h with the kernel 2019-10-15 12:44:00 -03:00
io_uring
kvm/kvm_stat
laptop
leds
lib libsubcmd: Use -O0 with DEBUG=1 2019-11-06 15:49:39 -03:00
memory-model
nfsd
objtool KVM: x86: Check kvm_rebooting in kvm_spurious_fault() 2019-09-25 15:23:33 +02:00
pci
pcmcia
perf perf map_groups: Add a front end cache for map lookups by name 2019-11-18 11:21:32 -03:00
power platform-drivers-x86 for v5.4-2 2019-09-24 12:39:40 -07:00
scripts
spi
testing Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2019-11-08 18:21:05 -08:00
thermal/tmon
time
usb usbip: tools: Fix read_usb_vudc_device() error path handling 2019-10-28 17:51:06 +01:00
virtio tools/virtio: xen stub 2019-10-13 09:38:27 -04:00
vm
wmi
Makefile