Commit 82e38a50 authored by Alexei Starovoitov's avatar Alexei Starovoitov

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: default avatarAndrii Nakryiko <andrii@kernel.org>
Fixes: 8290dba5 ("selftests/bpf: wq: add bpf_wq_start() checks")
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 5305b378
...@@ -31,6 +31,7 @@ void serial_test_wq(void) ...@@ -31,6 +31,7 @@ void serial_test_wq(void)
usleep(50); /* 10 usecs should be enough, but give it extra */ usleep(50); /* 10 usecs should be enough, but give it extra */
ASSERT_EQ(wq_skel->bss->ok_sleepable, (1 << 1), "ok_sleepable"); ASSERT_EQ(wq_skel->bss->ok_sleepable, (1 << 1), "ok_sleepable");
wq__destroy(wq_skel);
} }
void serial_test_failures_wq(void) void serial_test_failures_wq(void)
......
...@@ -368,9 +368,23 @@ int delete_module(const char *name, int flags) ...@@ -368,9 +368,23 @@ int delete_module(const char *name, int flags)
int unload_bpf_testmod(bool verbose) int unload_bpf_testmod(bool verbose)
{ {
int ret, cnt = 0;
if (kern_sync_rcu()) if (kern_sync_rcu())
fprintf(stdout, "Failed to trigger kernel-side RCU sync!\n"); 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 (errno == ENOENT) {
if (verbose) if (verbose)
fprintf(stdout, "bpf_testmod.ko is already unloaded.\n"); fprintf(stdout, "bpf_testmod.ko is already unloaded.\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment