summaryrefslogtreecommitdiff
path: root/samples/bpf/spintest.bpf.c
diff options
context:
space:
mode:
authorDaniel T. Lee <danieltimlee@gmail.com>2023-08-18 18:01:19 +0900
committerAlexei Starovoitov <ast@kernel.org>2023-08-21 15:39:10 -0700
commit456d53554ca7e93d7e5e8eb7fe8c906d5ec6e7d0 (patch)
tree4fd7df7b9f5d0c1d6627867b16b32ef113e5188a /samples/bpf/spintest.bpf.c
parent8dc80551463197ec79ce0966ec2b5bd700042614 (diff)
samples/bpf: simplify spintest with kprobe.multi
With the introduction of kprobe.multi, it is now possible to attach multiple kprobes to a single BPF program without the need for multiple definitions. Additionally, this method supports wildcard-based matching, allowing for further simplification of BPF programs. In here, an asterisk (*) wildcard is used to map to all symbols relevant to spin_{lock|unlock}. Furthermore, since kprobe.multi handles symbol matching, this commit eliminates the need for the previous logic of reading the ksym table to verify the existence of symbols. Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> Link: https://lore.kernel.org/r/20230818090119.477441-10-danieltimlee@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'samples/bpf/spintest.bpf.c')
-rw-r--r--samples/bpf/spintest.bpf.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/samples/bpf/spintest.bpf.c b/samples/bpf/spintest.bpf.c
index 15740b16a3f7..cba5a9d50783 100644
--- a/samples/bpf/spintest.bpf.c
+++ b/samples/bpf/spintest.bpf.c
@@ -47,20 +47,9 @@ int foo(struct pt_regs *ctx) \
}
/* add kprobes to all possible *spin* functions */
-SEC("kprobe/spin_unlock")PROG(p1)
-SEC("kprobe/spin_lock")PROG(p2)
-SEC("kprobe/mutex_spin_on_owner")PROG(p3)
-SEC("kprobe/rwsem_spin_on_owner")PROG(p4)
-SEC("kprobe/spin_unlock_irqrestore")PROG(p5)
-SEC("kprobe/_raw_spin_unlock_irqrestore")PROG(p6)
-SEC("kprobe/_raw_spin_unlock_bh")PROG(p7)
-SEC("kprobe/_raw_spin_unlock")PROG(p8)
-SEC("kprobe/_raw_spin_lock_irqsave")PROG(p9)
-SEC("kprobe/_raw_spin_trylock_bh")PROG(p10)
-SEC("kprobe/_raw_spin_lock_irq")PROG(p11)
-SEC("kprobe/_raw_spin_trylock")PROG(p12)
-SEC("kprobe/_raw_spin_lock")PROG(p13)
-SEC("kprobe/_raw_spin_lock_bh")PROG(p14)
+SEC("kprobe.multi/spin_*lock*")PROG(spin_lock)
+SEC("kprobe.multi/*_spin_on_owner")PROG(spin_on_owner)
+SEC("kprobe.multi/_raw_spin_*lock*")PROG(raw_spin_lock)
/* and to inner bpf helpers */
SEC("kprobe/htab_map_update_elem")PROG(p15)