WSL2-Linux-Kernel/tools/perf/util
Jiri Olsa b168852eb8 perf tools: Rework prologue generation code
Some functions we use for bpf prologue generation are going to be
deprecated. This change reworks current code not to use them.

We need to replace following functions/struct:
   bpf_program__set_prep
   bpf_program__nth_fd
   struct bpf_prog_prep_result

Currently we use bpf_program__set_prep to hook perf callback before
program is loaded and provide new instructions with the prologue.

We replace this function/ality by taking instructions for specific
program, attaching prologue to them and load such new ebpf programs
with prologue using separate bpf_prog_load calls (outside libbpf
load machinery).

Before we can take and use program instructions, we need libbpf to
actually load it. This way we get the final shape of its instructions
with all relocations and verifier adjustments).

There's one glitch though.. perf kprobe program already assumes
generated prologue code with proper values in argument registers,
so loading such program directly will fail in the verifier.

That's where the fallback pre-load handler fits in and prepends
the initialization code to the program. Once such program is loaded
we take its instructions, cut off the initialization code and prepend
the prologue.

I know.. sorry ;-)

To have access to the program when loading this patch adds support to
register 'fallback' section handler to take care of perf kprobe programs.
The fallback means that it handles any section definition besides the
ones that libbpf handles.

The handler serves two purposes:
  - allows perf programs to have special arguments in section name
  - allows perf to use pre-load callback where we can attach init
    code (zeroing all argument registers) to each perf program

Suggested-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/bpf/20220616202214.70359-2-jolsa@kernel.org
2022-06-24 13:36:23 -07:00
..
arm-spe-decoder
bpf_skel perf record: Add cgroup support for off-cpu profiling 2022-05-26 12:36:58 -03:00
c++ perf clang: Fix header include for LLVM >= 14 2022-04-22 18:39:34 -03:00
cs-etm-decoder
include linkage: remove SYM_FUNC_{START,END}_ALIAS() 2022-02-22 16:21:34 +00:00
intel-pt-decoder perf intel-pt: Add support for emulated ptwrite 2022-05-17 11:55:49 -03:00
libunwind perf unwind arm64: Use perf's copy of kernel headers 2022-05-26 12:36:58 -03:00
scripting-engines perf scripting python: Expose dso and map information 2022-05-27 13:22:13 -03:00
Build perf record: Enable off-cpu analysis with BPF 2022-05-26 12:36:57 -03:00
PERF-VERSION-GEN perf tools: Fix version kernel tag 2022-03-22 17:12:40 -03:00
affinity.c
affinity.h
amd-sample-raw.c
annotate.c perf annotate: Drop objdump stderr to avoid getting stuck waiting for stdout output 2022-04-09 14:21:00 -03:00
annotate.h
archinsn.h
arm-spe.c perf arm-spe: Fix SPE events with phys addresses 2022-04-28 10:39:28 -03:00
arm-spe.h
arm64-frame-pointer-unwind-support.c perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
arm64-frame-pointer-unwind-support.h
auxtrace.c perf tools: Allow all_cpus to be a superset of user_requested_cpus 2022-05-26 12:36:57 -03:00
auxtrace.h perf auxtrace: Remove auxtrace_mmap_params__set_idx() per_cpu parameter 2022-05-26 12:36:57 -03:00
block-info.c
block-info.h
block-range.c
block-range.h
bpf-event.c perf build: Stop using __weak btf__raw_data() to handle older libbpf versions 2022-05-26 11:02:02 -03:00
bpf-event.h
bpf-loader.c perf tools: Rework prologue generation code 2022-06-24 13:36:23 -07:00
bpf-loader.h
bpf-prologue.c
bpf-prologue.h
bpf-utils.c
bpf-utils.h
bpf_counter.c perf build: Stop using __weak bpf_map_create() to handle older libbpf versions 2022-05-26 12:36:56 -03:00
bpf_counter.h
bpf_counter_cgroup.c perf cpumap: Switch to using perf_cpu_map API 2022-05-05 14:07:27 -03:00
bpf_ftrace.c perf evlist: Rename cpus to user_requested_cpus 2022-04-01 16:19:35 -03:00
bpf_map.c
bpf_map.h
bpf_off_cpu.c perf record: Add cgroup support for off-cpu profiling 2022-05-26 12:36:58 -03:00
branch.c perf: Add irq and exception return branch types 2022-03-01 16:19:01 +01:00
branch.h
build-id.c perf build-id: Fix spelling mistake "Cant" -> "Can't" 2022-03-22 18:27:56 -03:00
build-id.h
cache.h
cacheline.c
cacheline.h
call-path.c
call-path.h
callchain.c
callchain.h
cap.c
cap.h
cgroup.c
cgroup.h
clockid.c
clockid.h
cloexec.c
cloexec.h
color.c
color.h
color_config.c
comm.c
comm.h
compress.h
config.c
config.h
copyfile.c
copyfile.h
counts.c
counts.h
cpu-set-sched.h
cpumap.c
cpumap.h
cputopo.c
cputopo.h
cs-etm.c perf cs-etm: Fix corrupt inject files when only last branch option is enabled 2022-02-16 13:49:25 -03:00
cs-etm.h
data-convert-bt.c
data-convert-json.c
data-convert.h
data.c perf data: Add has_kcore_dir() 2022-05-23 10:11:39 -03:00
data.h perf data: Add has_kcore_dir() 2022-05-23 10:11:39 -03:00
db-export.c
db-export.h
debug.c
debug.h
demangle-java.c
demangle-java.h
demangle-ocaml.c
demangle-ocaml.h
demangle-rust.c
demangle-rust.h
dlfilter.c
dlfilter.h
dso.c
dso.h perf unwind: Fix segbase for ld.lld linked objects 2022-06-03 21:20:25 +02:00
dsos.c
dsos.h
dump-insn.c
dump-insn.h
dwarf-aux.c
dwarf-aux.h
dwarf-regs.c
env.c
env.h
event.c perf tools: Add guest_code support 2022-05-23 10:18:38 -03:00
event.h perf intel-pt: Synthesize CFE (Control Flow Event) / EVD (Event Data) event 2022-02-15 17:12:13 -03:00
events_stats.h
evlist-hybrid.c perf evlist: Fix failed to use cpu list for uncore events 2022-02-18 09:59:26 -03:00
evlist-hybrid.h
evlist.c perf evlist: Add evlist__add_dummy_on_all_cpus() 2022-05-26 12:36:57 -03:00
evlist.h perf evlist: Add evlist__add_dummy_on_all_cpus() 2022-05-26 12:36:57 -03:00
evsel.c perf unwind: Use dynamic register set for DWARF unwind 2022-05-26 12:41:36 -03:00
evsel.h perf stat: Always keep perf metrics topdown events in a group 2022-05-20 11:11:13 -03:00
evsel_config.h
evsel_fprintf.c
evsel_fprintf.h
evswitch.c
evswitch.h
expr.c
expr.h
expr.l
expr.y
find-map.c
fncache.c
fncache.h
ftrace.h perf ftrace latency: Add -n/--use-nsec option 2022-03-22 17:43:46 -03:00
genelf.c
genelf.h perf jitdump: Add riscv64 support 2022-04-11 16:37:26 -03:00
genelf_debug.c
generate-cmdlist.sh
get_current_dir_name.c
get_current_dir_name.h
hashmap.c perf tools: Update copy of libbpf's hashmap.c 2022-04-01 16:19:34 -03:00
hashmap.h
header.c perf inject: Keep some features sections from input file 2022-05-23 10:11:25 -03:00
header.h perf inject: Keep some features sections from input file 2022-05-23 10:11:25 -03:00
help-unknown-cmd.c
help-unknown-cmd.h
hist.c perf report: Add "addr_from" and "addr_to" sort dimensions 2022-02-16 11:21:22 -03:00
hist.h perf report: Add "addr_from" and "addr_to" sort dimensions 2022-02-16 11:21:22 -03:00
intel-bts.c
intel-bts.h
intel-pt.c perf intel-pt: Add guest_code support 2022-05-23 10:19:24 -03:00
intel-pt.h
intlist.c
intlist.h
iostat.c
iostat.h
jit.h
jitdump.c
jitdump.h
kvm-stat.h
levenshtein.c
levenshtein.h
llvm-utils.c
llvm-utils.h
lzma.c
machine.c perf tools: Add guest_code support 2022-05-23 10:18:38 -03:00
machine.h perf tools: Add guest_code support 2022-05-23 10:18:38 -03:00
map.c perf tools: Set build-id using build-id header on new mmap records 2022-03-12 11:01:12 -03:00
map.h perf map: Make map__contains_symbol() args const 2022-02-14 16:59:55 -03:00
map_symbol.h
maps.c perf maps: Move maps code to own C file 2022-02-14 16:56:32 -03:00
maps.h
mem-events.c perf mem: Add stats for store operation with no available memory level 2022-05-23 09:36:12 -03:00
mem-events.h perf mem: Add stats for store operation with no available memory level 2022-05-23 09:36:12 -03:00
mem2node.c
mem2node.h
memswap.c
memswap.h
metricgroup.c perf metrics: Don't add all tool events for sharing 2022-05-09 10:18:48 -03:00
metricgroup.h
mmap.c perf auxtrace: Remove auxtrace_mmap_params__set_idx() per_cpu parameter 2022-05-26 12:36:57 -03:00
mmap.h
namespaces.c
namespaces.h
off_cpu.h perf record: Add cgroup support for off-cpu profiling 2022-05-26 12:36:58 -03:00
ordered-events.c
ordered-events.h
parse-branch-options.c
parse-branch-options.h
parse-events-hybrid.c
parse-events-hybrid.h
parse-events.c perf stat: Add requires_cpu flag for uncore 2022-05-26 12:36:57 -03:00
parse-events.h
parse-events.l perf stat: Add user_time and system_time events 2022-04-20 13:44:56 -03:00
parse-events.y
parse-regs-options.c
parse-regs-options.h
parse-sublevel-options.c
parse-sublevel-options.h
path.c perf test: Shell - Limit to only run executable scripts in tests 2022-04-11 16:39:49 -03:00
path.h perf test: Shell - Limit to only run executable scripts in tests 2022-04-11 16:39:49 -03:00
perf-hooks-list.h
perf-hooks.c
perf-hooks.h
perf_api_probe.c
perf_api_probe.h
perf_event_attr_fprintf.c
perf_regs.c perf tools arm64: Add support for VG register 2022-05-27 13:21:33 -03:00
perf_regs.h
pfm.c
pfm.h
pmu-hybrid.c
pmu-hybrid.h
pmu.c
pmu.h
pmu.l
pmu.y
print_binary.c
print_binary.h
probe-event.c
probe-event.h
probe-file.c
probe-file.h
probe-finder.c
probe-finder.h
pstack.c
pstack.h
python-ext-sources perf unwind: Use dynamic register set for DWARF unwind 2022-05-26 12:41:36 -03:00
python.c perf python: Add perf_env stubs that will be needed in evsel__open_strerror() 2022-03-26 10:55:57 -03:00
rb_resort.h
rblist.c
rblist.h
record.c perf evlist: Rename cpus to user_requested_cpus 2022-04-01 16:19:35 -03:00
record.h
rlimit.c
rlimit.h
rwsem.c
rwsem.h
s390-cpumcf-kernel.h
s390-cpumsf-kernel.h
s390-cpumsf.c
s390-cpumsf.h
s390-sample-raw.c
sample-raw.c
sample-raw.h
session.c perf tools: Add guest_code support 2022-05-23 10:18:38 -03:00
session.h
setns.c
setup.py perf build: Don't use -ffat-lto-objects in the python feature test when building with clang-13 2022-04-09 12:34:29 -03:00
sideband_evlist.c perf evlist: Rename cpus to user_requested_cpus 2022-04-01 16:19:35 -03:00
smt.c
smt.h
sort.c perf report: Add "addr_from" and "addr_to" sort dimensions 2022-02-16 11:21:22 -03:00
sort.h perf report: Add "addr_from" and "addr_to" sort dimensions 2022-02-16 11:21:22 -03:00
spark.c
spark.h
srccode.c
srccode.h
srcline.c
srcline.h
stat-display.c perf stat: Make use of index clearer with perf_counts 2022-05-23 09:54:02 -03:00
stat-shadow.c perf metrics: Support all tool events 2022-05-09 10:16:49 -03:00
stat.c perf stat: Make use of index clearer with perf_counts 2022-05-23 09:54:02 -03:00
stat.h perf stat: Merge event counts from all hybrid PMUs 2022-04-22 14:23:35 -03:00
strbuf.c
strbuf.h
stream.c
stream.h
strfilter.c
strfilter.h
string.c
string2.h
strlist.c
strlist.h
svghelper.c
svghelper.h
symbol-elf.c perf symbol: Pass is_kallsyms to symbols__fixup_end() 2022-04-28 10:51:20 -03:00
symbol-minimal.c
symbol.c perf symbol: Remove arch__symbols__fixup_end() 2022-04-28 10:51:40 -03:00
symbol.h perf symbol: Remove arch__symbols__fixup_end() 2022-04-28 10:51:40 -03:00
symbol_conf.h perf tools: Add guest_code support 2022-05-23 10:18:38 -03:00
symbol_fprintf.c
symsrc.h
synthetic-events.c perf evlist: Rename cpus to user_requested_cpus 2022-04-01 16:19:35 -03:00
synthetic-events.h
syscalltbl.c
syscalltbl.h
target.c
target.h
term.c
term.h
thread-stack.c
thread-stack.h
thread.c
thread.h
thread_map.c
thread_map.h
time-utils.c
time-utils.h
tool.h
top.c perf evlist: Rename cpus to user_requested_cpus 2022-04-01 16:19:35 -03:00
top.h perf tui: Only support --tui with slang 2022-02-15 17:15:29 -03:00
topdown.c perf stat: Support hybrid --topdown option 2022-04-24 07:50:18 -03:00
topdown.h perf stat: Support hybrid --topdown option 2022-04-24 07:50:18 -03:00
trace-event-info.c
trace-event-parse.c perf tools: Use ARRAY_SIZE() instead of ad hoc equivalent, spotted by array_size.cocci 2022-03-07 14:54:54 -03:00
trace-event-read.c
trace-event-scripting.c
trace-event.c
trace-event.h
trigger.h
tsc.c
tsc.h
units.c
units.h
unwind-libdw.c perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
unwind-libdw.h perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
unwind-libunwind-local.c perf unwind: Fix segbase for ld.lld linked objects 2022-06-03 21:20:25 +02:00
unwind-libunwind.c perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
unwind.h perf unwind: Don't show unwind error messages when augmenting frame pointer stack 2022-04-09 12:34:29 -03:00
usage.c
util.c perf tools: Print warning when HAVE_DEBUGINFOD_SUPPORT is not set and user tries to use debuginfod support 2022-04-20 13:36:36 -03:00
util.h
values.c
values.h
vdso.c
vdso.h
zlib.c
zstd.c