diff options
author | Daniel T. Lee <danieltimlee@gmail.com> | 2022-12-24 08:15:22 +0100 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2022-12-29 23:22:34 +0100 |
commit | 1d0c5f6f3d1387ec9c3a379fb232c078f5838d55 (patch) | |
tree | 3e4c4447088e9a1124e6e5ebe447479d1f094d2e /samples/bpf/tracex2_kern.c | |
parent | bpf: rename list_head -> graph_root in field info types (diff) | |
download | linux-1d0c5f6f3d1387ec9c3a379fb232c078f5838d55.tar.xz linux-1d0c5f6f3d1387ec9c3a379fb232c078f5838d55.zip |
samples/bpf: Use kyscall instead of kprobe in syscall tracing program
Syscall tracing using kprobe is quite unstable. Since it uses the exact
name of the kernel function, the program might broke due to the rename
of a function. The problem can also be caused by a changes in the
arguments of the function to which the kprobe connects.
In this commit, ksyscall is used instead of kprobe. By using ksyscall,
libbpf will detect the appropriate kernel function name.
(e.g. sys_write -> __s390_sys_write). This eliminates the need to worry
about which wrapper function to attach in order to parse arguments.
In addition, ksyscall provides more fine method with attaching system
call, the coarse SYSCALL helper at trace_common.h can be removed.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20221224071527.2292-2-danieltimlee@gmail.com
Diffstat (limited to 'samples/bpf/tracex2_kern.c')
-rw-r--r-- | samples/bpf/tracex2_kern.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/samples/bpf/tracex2_kern.c b/samples/bpf/tracex2_kern.c index 93e0b7680b4f..82091facb83c 100644 --- a/samples/bpf/tracex2_kern.c +++ b/samples/bpf/tracex2_kern.c @@ -10,7 +10,6 @@ #include <uapi/linux/bpf.h> #include <bpf/bpf_helpers.h> #include <bpf/bpf_tracing.h> -#include "trace_common.h" struct { __uint(type, BPF_MAP_TYPE_HASH); @@ -78,7 +77,7 @@ struct { __uint(max_entries, 1024); } my_hist_map SEC(".maps"); -SEC("kprobe/" SYSCALL(sys_write)) +SEC("ksyscall/write") int bpf_prog3(struct pt_regs *ctx) { long write_size = PT_REGS_PARM3(ctx); |