linux-stable/tools/perf
Song Liu d56354dc49 perf tools: Save bpf_prog_info and BTF of new BPF programs
To fully annotate BPF programs with source code mapping, 4 different
information are needed:

    1) PERF_RECORD_KSYMBOL
    2) PERF_RECORD_BPF_EVENT
    3) bpf_prog_info
    4) btf

This patch handles 3) and 4) for BPF programs loaded after 'perf
record|top'.

For timely process of these information, a dedicated event is added to
the side band evlist.

When PERF_RECORD_BPF_EVENT is received via the side band event, the
polling thread gathers 3) and 4) vis sys_bpf and store them in perf_env.

This information is saved to perf.data at the end of 'perf record'.

Committer testing:

The 'wakeup_watermark' member in 'struct perf_event_attr' is inside a
unnamed union, so can't be used in a struct designated initialization
with older gccs, get it out of that, isolating as 'attr.wakeup_watermark
= 1;' to work with all gcc versions.

We also need to add '--no-bpf-event' to the 'perf record'
perf_event_attr tests in 'perf test', as the way that that test goes is
to intercept the events being setup and looking if they match the fields
described in the control files, since now it finds first the side band
event used to catch the PERF_RECORD_BPF_EVENT, they all fail.

With these issues fixed:

Same scenario as for testing BPF programs loaded before 'perf record' or
'perf top' starts, only start the BPF programs after 'perf record|top',
so that its information get collected by the sideband threads, the rest
works as for the programs loaded before start monitoring.

Add missing 'inline' to the bpf_event__add_sb_event() when
HAVE_LIBBPF_SUPPORT is not defined, fixing the build in systems without
binutils devel files installed.

Signed-off-by: Song Liu <songliubraving@fb.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stanislav Fomichev <sdf@google.com>
Link: http://lkml.kernel.org/r/20190312053051.2690567-16-songliubraving@fb.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-03-21 11:27:04 -03:00
..
arch perf tools: Update x86's syscall_64.tbl, no change in tools/perf behaviour 2019-03-11 16:13:04 -03:00
bench perf tools: Fix errors under optimization level '-Og' 2019-03-19 16:52:04 -03:00
Documentation perf config: Fix an error in the config template documentation 2019-03-19 16:52:04 -03:00
examples/bpf perf augmented_syscalls: Convert to bpf_map() 2019-01-25 15:12:11 +01:00
include/bpf perf bpf: Automatically add BTF ELF markers 2019-03-06 09:45:37 -03:00
jvmti perf jvmti: Separate jvmti cmlr check 2018-11-21 22:39:58 -03:00
pmu-events perf vendor events: Remove P8 HW events which are not supported 2019-03-19 16:52:03 -03:00
python
scripts perf script python: Add printdate function to SQL exporters 2019-03-11 16:13:02 -03:00
tests perf tools: Save bpf_prog_info and BTF of new BPF programs 2019-03-21 11:27:04 -03:00
trace perf beauty msg_flags: Add missing %s lost when adding prefix suppression logic 2019-03-01 15:45:35 -03:00
ui perf tools report: Add custom scripts to script menu 2019-03-11 16:33:20 -03:00
util perf tools: Save bpf_prog_info and BTF of new BPF programs 2019-03-21 11:27:04 -03:00
.gitignore
Build perf tools: Rename build libperf to perf 2019-02-14 15:18:08 -03:00
builtin-annotate.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-bench.c perf bench: Add epoll_ctl(2) benchmark 2018-11-21 22:39:55 -03:00
builtin-buildid-cache.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-buildid-list.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-c2c.c perf c2c: Fix c2c report for empty numa node 2019-03-06 18:15:24 -03:00
builtin-config.c perf config: Show the configuration when no arguments are provided 2018-12-18 12:24:00 -03:00
builtin-data.c
builtin-diff.c perf diff: Support --pid/--tid filter options 2019-03-06 18:06:16 -03:00
builtin-evlist.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-ftrace.c
builtin-help.c perf help: Remove needless use of strncpy() 2018-12-17 14:59:18 -03:00
builtin-inject.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-kallsyms.c pref tools: Add missing map.h includes 2019-02-06 10:00:38 -03:00
builtin-kmem.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-kvm.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-list.c perf list: Filter metrics too 2019-03-19 11:56:19 -03:00
builtin-lock.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-mem.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-probe.c perf namespaces: Remove namespaces.h from .h headers 2019-01-25 15:12:09 +01:00
builtin-record.c perf tools: Save bpf_prog_info and BTF of new BPF programs 2019-03-21 11:27:04 -03:00
builtin-report.c perf report: Show all sort keys in help output 2019-03-19 16:15:42 -03:00
builtin-sched.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-script.c perf script: Support relative time 2019-03-19 16:52:03 -03:00
builtin-stat.c perf stat: Fix --no-scale 2019-03-19 16:52:03 -03:00
builtin-timechart.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-top.c perf tools: Save bpf_prog_info and BTF of new BPF programs 2019-03-21 11:27:04 -03:00
builtin-trace.c perf data: Add global path holder 2019-02-22 16:52:07 -03:00
builtin-version.c
builtin.h perf script: Add array bound checking to list_scripts 2019-03-11 16:33:19 -03:00
check-headers.sh tools headers powerpc: Remove unistd.h 2019-01-10 10:42:08 -03:00
command-list.txt perf help: Add missing subcommand version 2018-09-19 14:53:36 -03:00
CREDITS
design.txt perf/doc: Update design.txt for exclude_{host|guest} flags 2019-01-21 11:01:18 +01:00
Makefile perf tools: Disable parallelism for 'make clean' 2018-08-20 08:54:58 -03:00
Makefile.config perf build: Check what binutils's 'disassembler()' signature to use 2019-03-20 16:42:10 -03:00
Makefile.perf perf tools: Rename LIB_FILE to LIBPERF_A 2019-02-14 15:18:08 -03:00
MANIFEST
perf-archive.sh
perf-completion.sh
perf-read-vdso.c perf tools: Make find_vdso_map() more modular 2019-01-08 13:28:13 -03:00
perf-sys.h
perf-with-kcore.sh
perf.c perf bpf: Save bpf_prog_info in a rbtree in perf_env 2019-03-19 16:52:06 -03:00
perf.h perf record: Replace option --bpf-event with --no-bpf-event 2019-03-19 16:52:06 -03:00