]> Gentwo Git Trees - linux/.git/commit
selftests/bpf: Add test to verify freeing the special fields in pcpu maps
authorLeon Hwang <leon.hwang@linux.dev>
Wed, 5 Nov 2025 15:14:07 +0000 (23:14 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 13 Nov 2025 17:15:33 +0000 (09:15 -0800)
commitc1cbf0d21c4194513248568e7ab935cf9bb92ff9
tree7f61f3e2cf0711d081239efd040d927c8439171c
parent6af6e49a76c9af7d42eb923703e7648cb2bf401a
selftests/bpf: Add test to verify freeing the special fields in pcpu maps

Add test to verify that updating [lru_,]percpu_hash maps decrements
refcount when BPF_KPTR_REF objects are involved.

The tests perform the following steps:
. Call update_elem() to insert an initial value.
. Use bpf_refcount_acquire() to increment the refcount.
. Store the node pointer in the map value.
. Add the node to a linked list.
. Probe-read the refcount and verify it is *2*.
. Call update_elem() again to trigger refcount decrement.
. Probe-read the refcount and verify it is *1*.

Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20251105151407.12723-3-leon.hwang@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/refcounted_kptr.c
tools/testing/selftests/bpf/progs/refcounted_kptr.c