selftests/bpf: Fix map_kptr test.
authorAlexei Starovoitov <ast@kernel.org>
Tue, 14 Feb 2023 23:50:51 +0000 (15:50 -0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Wed, 15 Feb 2023 17:24:59 +0000 (09:24 -0800)
commit62d101d5f422cde39b269f7eb4cbbe2f1e26f9d4
tree59b808098f150e0f6ac994adcb30f2bae2c271b0
parent5e53e5c7edc6d69b8cb48b3b370cfe531e4b4132
selftests/bpf: Fix map_kptr test.

The compiler is optimizing out majority of unref_ptr read/writes, so the test
wasn't testing much. For example, one could delete '__kptr' tag from
'struct prog_test_ref_kfunc __kptr *unref_ptr;' and the test would still "pass".

Convert it to volatile stores. Confirmed by comparing bpf asm before/after.

Fixes: 2cbc469a6fc3 ("selftests/bpf: Add C tests for kptr")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230214235051.22938-1-alexei.starovoitov@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/progs/map_kptr.c