Re: [PATCH bpf-next v6 5/5] selftests/bpf: Add ksock test for async callback guard
Mahe Tardy <[email protected]>
| Newsgroups | org.kernel.vger.bpf,org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 12, 2026 at 05:25:40PM +0000, [email protected] wrote: > > diff --git a/tools/testing/selftests/bpf/prog_tests/ksock_wq.c b/tools/testing/selftests/bpf/prog_tests/ksock_wq.c > > new file mode 100644 > > index 0000000000000..5b9c6cc303922 > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/prog_tests/ksock_wq.c > > @@ -0,0 +1,34 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* Copyright (c) 2026 Isovalent */ > > + > > +#include <unistd.h> > > + > > +#include "test_progs.h" > > +#include "ksock_wq.skel.h" > > + > > +void test_ksock_wq(void) > > +{ > > + LIBBPF_OPTS(bpf_test_run_opts, opts); > > + struct ksock_wq *skel; > > + int err; > > + > > + skel = ksock_wq__open_and_load(); > > + if (!ASSERT_OK_PTR(skel, "ksock_wq open and load")) > > + return; > > + > > + err = bpf_prog_test_run_opts( > > + bpf_program__fd(skel->progs.ksock_wq_start), &opts); > > + if (!ASSERT_OK(err, "run ksock_wq_start")) > > + goto out; > > + if (!ASSERT_OK(opts.retval, "ksock_wq_start retval")) > > + goto out; > > + > > + while (!__atomic_load_n(&skel->bss->callback_done, __ATOMIC_ACQUIRE)) > > + usleep(1000); > > What happens if the workqueue callback never runs or blocks? This loop is > unbounded, so the test would hang forever rather than failing. test_progs > has no per-test timeout, so a hang here would block the entire test run. > > Adding an iteration cap (e.g. a bounded retry count followed by an ASSERT > on callback_done) would turn a CI hang into a normal test failure. For > comparison, prog_tests/wq.c uses a bounded usleep(50) before asserting. Unsure how likely it is but it could be indeed improved in this way. > > > + > > + ASSERT_EQ(skel->bss->create_err, -EOPNOTSUPP, > > + "workqueue create rejected"); > > + > > +out: > > + ksock_wq__destroy(skel); > > +} > > [ ... ] > > > --- > AI reviewed your patch. Please fix the bug or email reply why it's not a bug. > See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md > > CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31618864886