Andrii Nakryiko 635599bace selftests/bpf: Sync RCU before unloading bpf_testmod
If some of the subtests use module BTFs through ksyms, they will cause
bpf_prog to take a refcount on bpf_testmod module, which will prevent it from
successfully unloading. Module's refcnt is decremented when bpf_prog is freed,
which generally happens in RCU callback. So we need to trigger
syncronize_rcu() in the kernel, which can be achieved nicely with
membarrier(MEMBARRIER_CMD_SHARED) or membarrier(MEMBARRIER_CMD_GLOBAL) syscall.
So do that in kernel_sync_rcu() and make it available to other test inside the
test_progs. This synchronize_rcu() is called before attempting to unload
bpf_testmod.

Fixes: 9f7fa225894c ("selftests/bpf: Add bpf_testmod kernel module for testing")
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Hao Luo <haoluo@google.com>
Link: https://lore.kernel.org/bpf/20210112075520.4103414-5-andrii@kernel.org
2021-01-12 17:23:47 -08:00
..
2020-12-07 14:34:55 -07:00
2020-10-15 15:14:32 -07:00
2020-06-29 10:02:23 +02:00
2020-12-20 10:44:05 -08:00
2020-12-17 13:34:25 -08:00
2020-08-07 11:33:27 -07:00
2020-06-09 10:03:12 -07:00
2020-12-16 00:17:58 -08:00
2020-08-05 10:28:25 -07:00
2020-12-16 00:17:58 -08:00