diff options
author | Alexei Starovoitov <ast@kernel.org> | 2024-04-24 13:57:18 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2024-04-24 14:05:05 -0700 |
commit | 82e38a505c9868e784ec31e743fd8a9fa5ca1084 (patch) | |
tree | 90df058db0db4dde730a1aff5fb2eb4119db8634 /tools | |
parent | 5305b378b351dc5fd55f5f1f37ef362ae0e11d7e (diff) | |
download | lwn-82e38a505c9868e784ec31e743fd8a9fa5ca1084.tar.gz lwn-82e38a505c9868e784ec31e743fd8a9fa5ca1084.zip |
selftests/bpf: Fix wq test.
The wq test was missing destroy(skel) part which was causing bpf progs to stay
loaded. That was causing test_progs to complain with
"Failed to unload bpf_testmod.ko from kernel: -11" message, but adding
destroy() wasn't enough, since wq callback may be delayed, so loop on unload of
bpf_testmod if errno is EAGAIN.
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Fixes: 8290dba51910 ("selftests/bpf: wq: add bpf_wq_start() checks")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/wq.c | 1 | ||||
-rw-r--r-- | tools/testing/selftests/bpf/testing_helpers.c | 16 |
2 files changed, 16 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/wq.c b/tools/testing/selftests/bpf/prog_tests/wq.c index 8a4a91d944cc..c4bacd3160e1 100644 --- a/tools/testing/selftests/bpf/prog_tests/wq.c +++ b/tools/testing/selftests/bpf/prog_tests/wq.c @@ -31,6 +31,7 @@ void serial_test_wq(void) usleep(50); /* 10 usecs should be enough, but give it extra */ ASSERT_EQ(wq_skel->bss->ok_sleepable, (1 << 1), "ok_sleepable"); + wq__destroy(wq_skel); } void serial_test_failures_wq(void) diff --git a/tools/testing/selftests/bpf/testing_helpers.c b/tools/testing/selftests/bpf/testing_helpers.c index 28b6646662af..d5379a0e6da8 100644 --- a/tools/testing/selftests/bpf/testing_helpers.c +++ b/tools/testing/selftests/bpf/testing_helpers.c @@ -368,9 +368,23 @@ int delete_module(const char *name, int flags) int unload_bpf_testmod(bool verbose) { + int ret, cnt = 0; + if (kern_sync_rcu()) fprintf(stdout, "Failed to trigger kernel-side RCU sync!\n"); - if (delete_module("bpf_testmod", 0)) { + + for (;;) { + ret = delete_module("bpf_testmod", 0); + if (!ret || errno != EAGAIN) + break; + if (++cnt > 10000) { + fprintf(stdout, "Unload of bpf_testmod timed out\n"); + break; + } + usleep(100); + } + + if (ret) { if (errno == ENOENT) { if (verbose) fprintf(stdout, "bpf_testmod.ko is already unloaded.\n"); |