]> git.baikalelectronics.ru Git - kernel.git/commit
perf: Enable branch record for software events
authorSong Liu <songliubraving@fb.com>
Fri, 10 Sep 2021 18:33:50 +0000 (11:33 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 13 Sep 2021 17:53:50 +0000 (10:53 -0700)
commitef9cf233f88e2a501c84bfc3745304c7621b3700
tree5a4286065571c6433ae43c49182fd8bbb9406c32
parent7c35cfc495940f2bc26f5821c11f86a58ddae521
perf: Enable branch record for software events

The typical way to access branch record (e.g. Intel LBR) is via hardware
perf_event. For CPUs with FREEZE_LBRS_ON_PMI support, PMI could capture
reliable LBR. On the other hand, LBR could also be useful in non-PMI
scenario. For example, in kretprobe or bpf fexit program, LBR could
provide a lot of information on what happened with the function. Add API
to use branch record for software use.

Note that, when the software event triggers, it is necessary to stop the
branch record hardware asap. Therefore, static_call is used to remove some
branch instructions in this process.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/bpf/20210910183352.3151445-2-songliubraving@fb.com
arch/x86/events/intel/core.c
arch/x86/events/intel/ds.c
arch/x86/events/intel/lbr.c
arch/x86/events/perf_event.h
include/linux/perf_event.h
kernel/events/core.c