Re: [PATCH v8 2/4] perf inject: add jitdump mmap injection support

From: Stephane Eranian
Date: Fri Jan 22 2016 - 16:23:01 EST


On Fri, Jan 22, 2016 at 12:44 PM, Arnaldo Carvalho de Melo
<acme@xxxxxxxxxx> wrote:
> Em Mon, Nov 30, 2015 at 10:02:21AM +0100, Stephane Eranian escreveu:
>> This patch adds a --jit/-j option to perf inject.
>>
>> This options injects MMAP records into the perf.data
>> file to cover the jitted code mmaps. It also emits
>> ELF images for each function in the jidump file.
>> Those images are created where the jitdump file is.
>> The MMAP records point to that location as well.
>>
>> Typical flow:
>> $ perf record -k mono -- java -agentpath:libpjvmti.so java_class
>> $ perf inject --jit -i perf.data -o perf.data.jitted
>> $ perf report -i perf.data.jitted
>
> So, it fails 'make -C tools/perf build-test', specifically the one where
> we ask for a NO_LIBELF build, trying to fix:
>
I have rebase to tip.git last night. Will try your branch today.
Will add a couple of minor adjustments and also better documentation
on how to use it.

> - make_no_libelf: cd . && make -f Makefile DESTDIR=/tmp/tmp.AzIgKZ2Y7K NO_LIBELF=1
> cd . && make -f Makefile DESTDIR=/tmp/tmp.AzIgKZ2Y7K NO_LIBELF=1
> BUILD: Doing 'make -j4' parallel build
>
> Auto-detecting system features:
> ... dwarf: [ on ]
> ... glibc: [ on ]
> ... gtk2: [ on ]
> ... libaudit: [ on ]
> ... libbfd: [ on ]
> ... libelf: [ on ]
> ... libnuma: [ on ]
> ... numa_num_possible_cpus: [ on ]
> ... libperl: [ on ]
> ... libpython: [ on ]
> ... libslang: [ on ]
> ... libcrypto: [ on ]
> ... libunwind: [ on ]
> ... libdw-dwarf-unwind: [ OFF ]
> ... zlib: [ on ]
> ... lzma: [ on ]
> ... get_cpuid: [ on ]
> ... bpf: [ on ]
>
> config/Makefile:364: Disabling post unwind, no support found.
> GEN common-cmds.h
> CC fd/array.o
> CC util/abspath.o
> LD fd/libapi-in.o
> CC fs/fs.o
> CC fs/tracing_path.o
> LD fs/libapi-in.o
> CC cpu.o
> CC event-parse.o
> LD libapi-in.o
> AR libapi.a
> CC util/alias.o
> CC event-plugin.o
> CC trace-seq.o
> CC parse-filter.o
> CC parse-utils.o
> CC kbuffer-parse.o
> CC arch/common.o
> LD libtraceevent-in.o
> LINK libtraceevent.a
> CC exec-cmd.o
> PERF_VERSION = 4.4.gac64671
> CC help.o
> CC plugin_jbd2.o
> CC util/annotate.o
> CC pager.o
> LD plugin_jbd2-in.o
> CC plugin_hrtimer.o
> CC parse-options.o
> LD plugin_hrtimer-in.o
> CC plugin_kmem.o
> CC run-command.o
> CC arch/x86/util/header.o
> LD plugin_kmem-in.o
> CC sigchain.o
> CC plugin_kvm.o
> CC subcmd-config.o
> LD plugin_kvm-in.o
> CC plugin_mac80211.o
> LD libsubcmd-in.o
> AR libsubcmd.a
> CC arch/x86/util/tsc.o
> LD plugin_mac80211-in.o
> CC plugin_sched_switch.o
> CC arch/x86/util/pmu.o
> LD plugin_sched_switch-in.o
> CC plugin_function.o
> CC plugin_xen.o
> LD plugin_function-in.o
> CC arch/x86/util/kvm-stat.o
> CC plugin_scsi.o
> LD plugin_xen-in.o
> CC plugin_cfg80211.o
> LD plugin_scsi-in.o
> LINK plugin_jbd2.so
> LD plugin_cfg80211-in.o
> LINK plugin_hrtimer.so
> CC arch/x86/tests/arch-tests.o
> LINK plugin_kmem.so
> CC arch/x86/tests/rdpmc.o
> LINK plugin_kvm.so
> LINK plugin_mac80211.so
> LINK plugin_sched_switch.so
> LINK plugin_function.so
> LINK plugin_xen.so
> CC arch/x86/util/perf_regs.o
> LINK plugin_scsi.so
> LINK plugin_cfg80211.so
> CC arch/x86/tests/perf-time-to-tsc.o
> GEN perf-archive
> CC arch/x86/util/auxtrace.o
> GEN perf-with-kcore
> CC ui/gtk/browser.o
> CC util/build-id.o
> CC arch/x86/util/intel-pt.o
> CC arch/x86/tests/insn-x86.o
> CC arch/x86/tests/intel-cqm.o
> CC util/config.o
> CC ui/gtk/hists.o
> CC arch/x86/util/intel-bts.o
> LD arch/x86/tests/libperf-in.o
> CC util/ctype.o
> CC util/db-export.o
> CC util/env.o
> LD arch/x86/util/libperf-in.o
> LD arch/x86/libperf-in.o
> LD arch/libperf-in.o
> CC ui/setup.o
> CC util/event.o
> CC util/evlist.o
> CC ui/helpline.o
> CC ui/gtk/setup.o
> CC ui/progress.o
> CC ui/util.o
> CC util/evsel.o
> CC ui/gtk/util.o
> CC ui/hist.o
> CC util/find_bit.o
> CC ui/gtk/helpline.o
> CC util/kallsyms.o
> CC util/levenshtein.o
> CC ui/gtk/progress.o
> CC util/llvm-utils.o
> BISON util/parse-events-bison.c
> CC util/perf_regs.o
> CC ui/gtk/annotate.o
> CC util/path.o
> CC util/rbtree.o
> CC util/libstring.o
> CC ui/stdio/hist.o
> CC util/bitmap.o
> CC util/hweight.o
> CC util/quote.o
> CC util/strbuf.o
> LD ui/gtk/gtk-in.o
> LD gtk-in.o
> CC util/string.o
> CC builtin-bench.o
> CC ui/browser.o
> CC util/strlist.o
> CC builtin-annotate.o
> CC util/strfilter.o
> CC util/top.o
> CC builtin-config.o
> CC ui/browsers/annotate.o
> CC util/usage.o
> CC builtin-diff.o
> CC util/wrapper.o
> CC util/dso.o
> CC util/symbol.o
> CC ui/browsers/hists.o
> CC builtin-evlist.o
> CC builtin-help.o
> CC ui/tui/setup.o
> CC util/color.o
> CC builtin-sched.o
> CC ui/tui/util.o
> CC util/header.o
> CC ui/tui/helpline.o
> CC ui/tui/progress.o
> LD ui/tui/libperf-in.o
> CC builtin-buildid-list.o
> CC builtin-buildid-cache.o
> CC builtin-list.o
> CC builtin-record.o
> CC builtin-report.o
> CC ui/browsers/map.o
> CC util/callchain.o
> CC ui/browsers/scripts.o
> CC builtin-stat.o
> CC builtin-timechart.o
> CC ui/browsers/header.o
> LD ui/browsers/libperf-in.o
> LD ui/libperf-in.o
> CC util/values.o
> CC scripts/perl/Perf-Trace-Util/Context.o
> CC util/debug.o
> CC builtin-top.o
> LD scripts/perl/Perf-Trace-Util/libperf-in.o
> CC scripts/python/Perf-Trace-Util/Context.o
> CC builtin-script.o
> CC util/machine.o
> LD scripts/python/Perf-Trace-Util/libperf-in.o
> LD scripts/libperf-in.o
> CC util/map.o
> CC builtin-kmem.o
> CC util/pstack.o
> CC util/session.o
> CC util/ordered-events.o
> CC builtin-lock.o
> CC util/comm.o
> CC builtin-kvm.o
> CC util/thread.o
> CC util/thread_map.o
> CC util/trace-event-parse.o
> CC builtin-inject.o
> CC builtin-mem.o
> CC builtin-data.o
> CC util/parse-events-bison.o
> CC builtin-version.o
> CC builtin-trace.o
> CC bench/sched-messaging.o
> CC tests/builtin-test.o
> BISON util/pmu-bison.c
> CC bench/sched-pipe.o
> CC util/trace-event-read.o
> CC tests/parse-events.o
> CC bench/mem-functions.o
> CC util/trace-event-info.o
> CC bench/futex-hash.o
> CC util/trace-event-scripting.o
> CC bench/futex-wake.o
> CC util/trace-event.o
> CC perf.o
> CC bench/futex-wake-parallel.o
> CC util/svghelper.o
> CC tests/dso-data.o
> CC bench/futex-requeue.o
> CC bench/futex-lock-pi.o
> CC bench/mem-memcpy-x86-64-asm.o
> CC bench/mem-memset-x86-64-asm.o
> CC bench/numa.o
> CC tests/attr.o
> CC tests/vmlinux-kallsyms.o
> CC util/sort.o
> CC tests/openat-syscall.o
> CC tests/openat-syscall-all-cpus.o
> CC tests/openat-syscall-tp-fields.o
> CC tests/mmap-basic.o
> CC tests/perf-record.o
> LD bench/perf-in.o
> CC tests/evsel-roundtrip-name.o
> CC tests/evsel-tp-sched.o
> CC tests/fdarray.o
> CC tests/pmu.o
> CC tests/hists_common.o
> CC tests/hists_link.o
> CC util/hist.o
> CC tests/hists_filter.o
> CC tests/hists_output.o
> CC tests/hists_cumulate.o
> CC tests/python-use.o
> CC tests/bp_signal.o
> CC util/util.o
> CC util/xyarray.o
> CC tests/bp_signal_overflow.o
> CC util/cpumap.o
> CC util/cgroup.o
> CC tests/task-exit.o
> CC util/target.o
> CC tests/sw-clock.o
> CC util/rblist.o
> CC util/intlist.o
> CC util/vdso.o
> CC util/counts.o
> CC tests/mmap-thread-lookup.o
> CC tests/thread-mg-share.o
> CC util/stat.o
> CC util/stat-shadow.o
> CC tests/switch-tracking.o
> CC tests/keep-tracking.o
> CC util/record.o
> CC util/srcline.o
> CC tests/code-reading.o
> CC tests/sample-parsing.o
> CC util/data.o
> CC tests/parse-no-sample-id-all.o
> CC util/tsc.o
> CC util/cloexec.o
> CC tests/kmod-path.o
> CC util/thread-stack.o
> CC tests/thread-map.o
> CC util/auxtrace.o
> CC tests/llvm.o
> CC tests/bpf.o
> CC util/intel-pt-decoder/intel-pt-pkt-decoder.o
> CC tests/topology.o
> CC tests/cpumap.o
> GEN util/intel-pt-decoder/inat-tables.c
> CC util/scripting-engines/trace-event-perl.o
> CC util/intel-pt-decoder/intel-pt-log.o
> CC tests/stat.o
> CC tests/event_update.o
> CC util/intel-pt-decoder/intel-pt-decoder.o
> CC tests/llvm-src-base.o
> CC tests/llvm-src-kbuild.o
> CC tests/llvm-src-prologue.o
> CC util/scripting-engines/trace-event-python.o
> LD tests/perf-in.o
> LD perf-in.o
> CC util/intel-pt.o
> CC util/intel-bts.o
> LD util/scripting-engines/libperf-in.o
> CC util/parse-branch-options.o
> GEN libtraceevent-dynamic-list
> CC util/intel-pt-decoder/intel-pt-insn-decoder.o
> CC util/parse-regs-options.o
> CC util/term.o
> CC util/help-unknown-cmd.o
> CC util/symbol-minimal.o
> CC util/zlib.o
> GEN python/perf.so
> CC util/lzma.o
> LD util/intel-pt-decoder/libperf-in.o
> CC util/demangle-java.o
> CC util/jitdump.o
> CC util/genelf.o
> FLEX util/parse-events-flex.c
> FLEX util/pmu-flex.c
> CC util/pmu-bison.o
> CC util/parse-events.o
> CC util/parse-events-flex.o
> CC util/pmu.o
> CC util/pmu-flex.o
> LD util/libperf-in.o
> LD libperf-in.o
> AR libperf.a
> LINK perf
> LINK libperf-gtk.so
> libperf.a(libperf-in.o): In function `jit_write_elf':
> /home/acme/git/linux/tools/perf/util/genelf.c:170: undefined reference to `elf_version'
> /home/acme/git/linux/tools/perf/util/genelf.c:175: undefined reference to `elf_begin'
> /home/acme/git/linux/tools/perf/util/genelf.c:184: undefined reference to `elf64_newehdr'
> /home/acme/git/linux/tools/perf/util/genelf.c:201: undefined reference to `elf_newscn'
> /home/acme/git/linux/tools/perf/util/genelf.c:207: undefined reference to `elf_newdata'
> /home/acme/git/linux/tools/perf/util/genelf.c:220: undefined reference to `elf64_getshdr'
> /home/acme/git/linux/tools/perf/util/genelf.c:235: undefined reference to `elf_newscn'
> /home/acme/git/linux/tools/perf/util/genelf.c:241: undefined reference to `elf_newdata'
> /home/acme/git/linux/tools/perf/util/genelf.c:254: undefined reference to `elf64_getshdr'
> /home/acme/git/linux/tools/perf/util/genelf.c:271: undefined reference to `elf_newscn'
> /home/acme/git/linux/tools/perf/util/genelf.c:277: undefined reference to `elf_newdata'
> /home/acme/git/linux/tools/perf/util/genelf.c:290: undefined reference to `elf64_getshdr'
> /home/acme/git/linux/tools/perf/util/genelf.c:314: undefined reference to `elf_newscn'
> /home/acme/git/linux/tools/perf/util/genelf.c:320: undefined reference to `elf_newdata'
> /home/acme/git/linux/tools/perf/util/genelf.c:333: undefined reference to `elf64_getshdr'
> /home/acme/git/linux/tools/perf/util/genelf.c:347: undefined reference to `elf_newscn'
> /home/acme/git/linux/tools/perf/util/genelf.c:353: undefined reference to `elf_newdata'
> /home/acme/git/linux/tools/perf/util/genelf.c:375: undefined reference to `elf64_getshdr'
> /home/acme/git/linux/tools/perf/util/genelf.c:388: undefined reference to `elf_update'
> /home/acme/git/linux/tools/perf/util/genelf.c:395: undefined reference to `elf_end'
> collect2: error: ld returned 1 exit status
> Makefile.perf:333: recipe for target 'perf' failed
> make[4]: *** [perf] Error 1
> make[4]: *** Waiting for unfinished jobs....
> Makefile:68: recipe for target 'all' failed
> make[3]: *** [all] Error 2
> test: test -x ./perf
> tests/make:273: recipe for target 'make_no_libelf' failed
> make[2]: *** [make_no_libelf] Error 1
> tests/make:7: recipe for target 'all' failed
> make[1]: *** [all] Error 2
> Makefile:81: recipe for target 'build-test' failed
> make: *** [build-test] Error 2
> make: Leaving directory '/home/acme/git/linux/tools/perf'
>
> Performance counter stats for 'make -C tools/perf build-test':
>
> 1007267.820554 task-clock (msec) # 2.516 CPUs utilized
> 591,484 context-switches # 0.587 K/sec
> 66,439 cpu-migrations # 0.066 K/sec
> 26,771,257 page-faults # 0.027 M/sec
> 2,863,648,588,724 cycles # 2.843 GHz
> <not supported> stalled-cycles-frontend
> <not supported> stalled-cycles-backend
> 2,459,464,718,802 instructions # 0.86 insns per cycle
> 547,848,880,912 branches # 543.896 M/sec
> 14,513,951,279 branch-misses # 2.65% of all branches
>
> 400.280077927 seconds time elapsed
>
> [acme@jouet linux]$
>