106dacd86f
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> |
||
---|---|---|
.. | ||
android.txt | ||
asciidoc.conf | ||
Build.txt | ||
callchain-overhead-calculation.txt | ||
examples.txt | ||
intel-bts.txt | ||
intel-pt.txt | ||
itrace.txt | ||
jit-interface.txt | ||
jitdump-specification.txt | ||
Makefile | ||
manpage-1.72.xsl | ||
manpage-base.xsl | ||
manpage-bold-literal.xsl | ||
manpage-normal.xsl | ||
manpage-suppress-sp.xsl | ||
perf-annotate.txt | ||
perf-archive.txt | ||
perf-bench.txt | ||
perf-buildid-cache.txt | ||
perf-buildid-list.txt | ||
perf-c2c.txt | ||
perf-config.txt | ||
perf-data.txt | ||
perf-diff.txt | ||
perf-evlist.txt | ||
perf-ftrace.txt | ||
perf-help.txt | ||
perf-inject.txt | ||
perf-kallsyms.txt | ||
perf-kmem.txt | ||
perf-kvm.txt | ||
perf-list.txt | ||
perf-lock.txt | ||
perf-mem.txt | ||
perf-probe.txt | ||
perf-record.txt | ||
perf-report.txt | ||
perf-sched.txt | ||
perf-script-perl.txt | ||
perf-script-python.txt | ||
perf-script.txt | ||
perf-stat.txt | ||
perf-test.txt | ||
perf-timechart.txt | ||
perf-top.txt | ||
perf-trace.txt | ||
perf.data-file-format.txt | ||
perf.txt | ||
perfconfig.example | ||
tips.txt |