diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2024-03-19 14:20:13 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2024-03-25 17:05:48 +0100 |
commit | a8497506cd2c0fc90a64f6f5d2744a0ddb2c81eb (patch) | |
tree | 8f76c6f63acd573e2bf281accc765b100e06f5ef /include/linux/overflow.h | |
parent | c29083f3f5069d811b3f3c7592a0dc45ec42960c (diff) |
bpf: Avoid get_kernel_nofault() to fetch kprobe entry IP
get_kernel_nofault() (or, rather, underlying copy_from_kernel_nofault())
is not free and it does pop up in performance profiles when
kprobes are heavily utilized with CONFIG_X86_KERNEL_IBT=y config.
Let's avoid using it if we know that fentry_ip - 4 can't cross page
boundary. We do that by masking lowest 12 bits and checking if they are
Another benefit (and actually what caused a closer look at this part of
code) is that now LBR record is (typically) not wasted on
copy_from_kernel_nofault() call and code, which helps tools like
retsnoop that grab LBR records from inside BPF code in kretprobes.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://lore.kernel.org/bpf/20240319212013.1046779-1-andrii@kernel.org
Diffstat (limited to 'include/linux/overflow.h')
0 files changed, 0 insertions, 0 deletions