Skip to content

Commit 82e38a5

Browse files
author
Alexei Starovoitov
committed
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 <[email protected]> Fixes: 8290dba ("selftests/bpf: wq: add bpf_wq_start() checks") Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 5305b37 commit 82e38a5

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tools/testing/selftests/bpf/prog_tests/wq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ void serial_test_wq(void)
3131
usleep(50); /* 10 usecs should be enough, but give it extra */
3232

3333
ASSERT_EQ(wq_skel->bss->ok_sleepable, (1 << 1), "ok_sleepable");
34+
wq__destroy(wq_skel);
3435
}
3536

3637
void serial_test_failures_wq(void)

tools/testing/selftests/bpf/testing_helpers.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,23 @@ int delete_module(const char *name, int flags)
368368

369369
int unload_bpf_testmod(bool verbose)
370370
{
371+
int ret, cnt = 0;
372+
371373
if (kern_sync_rcu())
372374
fprintf(stdout, "Failed to trigger kernel-side RCU sync!\n");
373-
if (delete_module("bpf_testmod", 0)) {
375+
376+
for (;;) {
377+
ret = delete_module("bpf_testmod", 0);
378+
if (!ret || errno != EAGAIN)
379+
break;
380+
if (++cnt > 10000) {
381+
fprintf(stdout, "Unload of bpf_testmod timed out\n");
382+
break;
383+
}
384+
usleep(100);
385+
}
386+
387+
if (ret) {
374388
if (errno == ENOENT) {
375389
if (verbose)
376390
fprintf(stdout, "bpf_testmod.ko is already unloaded.\n");

0 commit comments

Comments
 (0)