]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Refactor and simplify legacy kprobe code
authorAndrii Nakryiko <andrii@kernel.org>
Tue, 21 Sep 2021 21:00:35 +0000 (14:00 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 22 Sep 2021 02:40:09 +0000 (19:40 -0700)
commit91e2e483c4ab2b274611a7e853b1d7b534d9d9e5
tree26074d1d008f980efd19b239c75db77710e21fe0
parente84f74b0505e5875b0d5e0f9f58c01088d7df021
libbpf: Refactor and simplify legacy kprobe code

Refactor legacy kprobe handling code to follow the same logic as uprobe
legacy logic added in the next patchs:
  - add append_to_file() helper that makes it simpler to work with
    tracefs file-based interface for creating and deleting probes;
  - move out probe/event name generation outside of the code that
    adds/removes it, which simplifies bookkeeping significantly;
  - change the probe name format to start with "libbpf_" prefix and
    include offset within kernel function;
  - switch 'unsigned long' to 'size_t' for specifying kprobe offsets,
    which is consistent with how uprobes define that, simplifies
    printf()-ing internally, and also avoids unnecessary complications on
    architectures where sizeof(long) != sizeof(void *).

This patch also implicitly fixes the problem with invalid open() error
handling present in poke_kprobe_events(), which (the function) this
patch removes.

Fixes: 8b1e81171a1f ("libbpf: Introduce legacy kprobe events support")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210921210036.1545557-4-andrii@kernel.org
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h