On Sat, 6 Aug 2022 at 03:46, Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> wrote: > > Add a regression test to check against invalid check_and_init_map_value > call inside prealloc_lru_pop. > > To actually observe a kind of problem this can cause, set debug to 1 > when running the test locally without the fix. Then, just observe the > refcount which keeps increasing on each run of the test. With timers or > spin locks, it would cause unpredictable results when racing. > > ... > > bash-5.1# ./test_progs -t lru_bug > test_progs-192 [000] d..21 354.838821: bpf_trace_printk: ref: 4 > test_progs-192 [000] d..21 354.842824: bpf_trace_printk: ref: 5 > bash-5.1# ./test_pogs -t lru_bug > test_progs-193 [000] d..21 356.722813: bpf_trace_printk: ref: 5 > test_progs-193 [000] d..21 356.727071: bpf_trace_printk: ref: 6 > > ... and so on. > > Signed-off-by: Kumar Kartikeya Dwivedi <memxor@xxxxxxxxx> > --- > .../selftests/bpf/prog_tests/lru_bug.c | 19 ++++++ > tools/testing/selftests/bpf/progs/lru_bug.c | 67 +++++++++++++++++++ > 2 files changed, 86 insertions(+) > create mode 100644 tools/testing/selftests/bpf/prog_tests/lru_bug.c > create mode 100644 tools/testing/selftests/bpf/progs/lru_bug.c > > diff --git a/tools/testing/selftests/bpf/prog_tests/lru_bug.c b/tools/testing/selftests/bpf/prog_tests/lru_bug.c > new file mode 100644 > index 000000000000..e77b2d9469cb > --- /dev/null > +++ b/tools/testing/selftests/bpf/prog_tests/lru_bug.c > @@ -0,0 +1,19 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include <test_progs.h> > + > +#include "lru_bug.skel.h" > + > +void test_lru_bug(void) CI is failing because map_kptr and this test both want to observe refcount when it is not being touched by either, so marking this serial_ would fix it (map_kptr takes time so it is better for it to run in parallel mode). I will wait for the discussion to conclude before respinning.