alistair23-linux/tools
Mark Santaniello 106dacd86f perf script: Support -F brstackoff,dso
The idea here is to make AutoFDO easier in cloud environment with ASLR.
It's easiest to show how this is useful by example. I built a small test
akin to "while(1) { do_nothing(); }" where the do_nothing function is
loaded from a dso:

  $ cat burncpu.cpp
  #include <dlfcn.h>

  int main() {
    void* handle = dlopen("./dso.so", RTLD_LAZY);
    if (!handle) return -1;

    typedef void (*fp)();
    fp do_nothing = (fp) dlsym(handle, "do_nothing");

    while(1) {
      do_nothing();
    }
  }

  $ cat dso.cpp
  extern "C" void do_nothing() {}

  $ cat build.sh
  #!/bin/bash
  g++ -shared dso.cpp -o dso.so
  g++ burncpu.cpp -o burncpu -ldl

I sampled the execution of this program with perf record -b.

Using the existing "brstack,dso", we get absolute addresses that are
affected by ASLR, and could be different on different hosts. The address
does not uniquely identify a branch/target in the binary:

  $ perf script -F brstack,dso | sed 's/\/0 /\/0\n/g' | grep burncpu | grep dso.so | head -n 1
  0x7f967139b6aa(/tmp/burncpu/dso.so)/0x4006b1(/tmp/burncpu/exe)/P/-/-/0

Using the existing "brstacksym,dso" is a little better, because the
symbol plus offset and dso name *does* uniquely identify a branch/target
in the binary.  Ultimately, however, AutoFDO wants a simple offset into
the binary, so we'd have to undo all the work perf did to symbolize in
the first place:

  $ perf script -F brstacksym,dso | sed 's/\/0 /\/0\n/g' | grep burncpu | grep dso.so | head -n 1
  do_nothing+0x5(/tmp/burncpu/dso.so)/main+0x44(/tmp/burncpu/exe)/P/-/-/0

With the new "brstackoff,dso" we get what we need: a simple offset into a
specific dso/binary that uniquely identifies a branch/target:
  $ perf script -F brstackoff,dso | sed 's/\/0 /\/0\n/g' | grep burncpu | grep dso.so | head -n 1
  0x6aa(/tmp/burncpu/dso.so)/0x4006b1(/tmp/burncpu/exe)/P/-/-/0

Signed-off-by: Mark Santaniello <marksan@fb.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20170619163825.2012979-2-marksan@fb.com
[ Updated documentation about 'brstackoff' using text from above ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-06-19 22:05:46 -03:00
..
accounting tools: move accounting tool from Documentation 2016-09-23 13:07:15 -06:00
arch tools/include: Sync kernel ABI headers with tooling headers 2017-05-24 09:00:21 +02:00
build Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-05-15 15:50:49 -07:00
cgroup
firewire
gpio gpio-hammer: fix make consumer_label suitable to work on gpio-nails 2017-01-26 16:29:09 +01:00
hv tools: hv: Add clean up function for Ubuntu config 2017-03-06 17:10:40 -08:00
iio iio: Add channel for Gravity 2017-01-05 13:02:25 +00:00
include tools: Adopt __aligned from kernel sources 2017-06-19 15:27:08 -03:00
kvm/kvm_stat tools/kvm_stat: add '%Total' column 2017-03-29 12:01:33 +02:00
laptop tools: move laptops dslm tool from Documentation 2016-09-23 13:07:21 -06:00
leds tools/leds: Add led_hw_brightness_mon program 2017-02-14 22:20:23 +01:00
lguest Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-05-01 20:51:12 -07:00
lib Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2017-05-15 15:50:49 -07:00
net tools: bpf_jit_disasm: Add option to dump JIT image to a file. 2017-04-13 13:04:03 -04:00
nfsd
objtool objtool: Drop ARRAY_SIZE() definition, tools/include/linux/kernel.h has it now 2017-04-19 13:01:44 -03:00
pci tools: PCI: Add sample test script to invoke pcitest 2017-04-28 10:23:20 -05:00
pcmcia tools: move pcmcia crc32hash tool from Documentation 2016-09-23 13:07:27 -06:00
perf perf script: Support -F brstackoff,dso 2017-06-19 22:05:46 -03:00
power Merge branches 'acpi-button' and 'acpi-tools' 2017-05-22 20:29:06 +02:00
scripts tools arch x86: Include asm/cmpxchg.h 2017-03-03 19:07:13 -03:00
spi spi: spidev_test: add option to continuously transfer data 2017-03-21 18:44:40 +00:00
testing powerpc fixes for 4.12 #4 2017-05-27 09:28:34 -07:00
thermal/tmon
time
usb usb: fix some references for /proc/bus/usb 2017-04-18 16:54:19 +02:00
virtio tools/virtio: fix spelling mistake: "wakeus" -> "wakeups" 2017-05-09 16:43:24 +03:00
vm tools/vm: add missing Makefile rules 2017-02-22 16:41:26 -08:00
Makefile tools/kvm: fix top level makefile 2017-05-03 16:30:25 +02:00