bpf: Add kmem_cache iterator
authorNamhyung Kim <namhyung@kernel.org>
Thu, 10 Oct 2024 23:25:03 +0000 (16:25 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 15 Oct 2024 01:33:04 +0000 (18:33 -0700)
commit4971266e1595f76be3f844c834c1f9357a97dbde
treed51a010cdaf2492e184bfdc85c68836c50e7a6fa
parent989a29cfed9b5092c3e18be14e9032c51bb1c9f6
bpf: Add kmem_cache iterator

The new "kmem_cache" iterator will traverse the list of slab caches
and call attached BPF programs for each entry.  It should check the
argument (ctx.s) if it's NULL before using it.

Now the iteration grabs the slab_mutex only if it traverse the list and
releases the mutex when it runs the BPF program.  The kmem_cache entry
is protected by a refcount during the execution.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz> #slab
Link: https://lore.kernel.org/r/20241010232505.1339892-2-namhyung@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/btf_ids.h
kernel/bpf/Makefile
kernel/bpf/kmem_cache_iter.c [new file with mode: 0644]