From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 5/5] selftests/sched_ext: Bound exit waits and report reload_loop failures
Date: Fri, 09 Oct 2026 13:48:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-165673@kernel.org> (raw)
In-Reply-To: <20261009134104.296891-6-cui.tao@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] selftests/sched_ext: leak of BPF link and skeleton on timeout in exit.c
- [Low] selftests/sched_ext: dead code in reload_loop failure reporting
--
commit b49c5aa1d20c7dfda172f19617a72ddbef7da918
Author: Tao Cui <cuitao@kylinos.cn>
selftests/sched_ext: Bound exit waits and report reload_loop failures
This commit replaces unbounded waits for scheduler exit in multiple tests
with an iteration-bound timeout using SCX_TIMED_WAIT_UEI(). It also updates
reload_loop to track and report attach failures, failing the test on
unexpected errors or if every attach attempt fails.
> diff --git a/tools/testing/selftests/sched_ext/exit.c b/tools/testing/selftests/sched_ext/exit.c
> index 01b17092d5c8f..9270d8e79eb63 100644
> --- a/tools/testing/selftests/sched_ext/exit.c
> +++ b/tools/testing/selftests/sched_ext/exit.c
> @@ -43,8 +43,8 @@ static enum scx_test_status run(void *ctx)
> }
>
> /* Assumes uei.kind is written last */
> - while (skel->data->uei.kind == EXIT_KIND(SCX_EXIT_NONE))
> - sched_yield();
> + SCX_FAIL_IF(!SCX_TIMED_WAIT_UEI(skel, uei, 10000),
> + "Timed out waiting for scheduler to exit");
>
[Severity: Medium]
Does this SCX_FAIL_IF() check leak the BPF link and skeleton on timeout?
In run(), skel and link are allocated locally inside the loop. If the wait
times out, SCX_FAIL_IF() will immediately return SCX_TEST_FAIL, bypassing
the bpf_link__destroy() and exit__destroy() calls at the end of the loop block.
Failing to destroy the BPF link leaves the scheduler attached to the kernel,
which breaks test isolation. Subsequent tests in the runner might then fail
with -EBUSY because only one sched_ext scheduler can be attached at a time.
> SCX_EQ(skel->data->uei.kind, EXIT_KIND(SCX_EXIT_UNREG_BPF));
> SCX_EQ(skel->data->uei.exit_code, tc);
[ ... ]
> diff --git a/tools/testing/selftests/sched_ext/reload_loop.c b/tools/testing/selftests/sched_ext/reload_loop.c
> index ecff86f59e6c7..4ae6fb43b6c5c 100644
> --- a/tools/testing/selftests/sched_ext/reload_loop.c
> +++ b/tools/testing/selftests/sched_ext/reload_loop.c
[ ... ]
> @@ -60,7 +78,24 @@ static enum scx_test_status run(void *ctx)
> }
>
> SCX_FAIL_IF(pthread_join(threads[0], &ret), "thread 0 failed");
> + failures += (unsigned long)ret;
> +
> SCX_FAIL_IF(pthread_join(threads[1], &ret), "thread 1 failed");
> + failures += (unsigned long)ret;
> +
> + SCX_FAIL_IF(unexpected_errno, "unexpected attach errno %d",
> + unexpected_errno);
> +
> + if (failures) {
> + printf("reload_loop: %lu attach failures%s\n",
> + (unsigned long)failures,
> + unexpected_errno ? ", unexpected errno" :
> + " (EBUSY: scheduler slot busy)");
[Severity: Low]
Is the true branch of this ternary condition dead code?
The SCX_FAIL_IF(unexpected_errno, ...) check slightly above will immediately
return from the function if unexpected_errno is non-zero. As a result, when
execution reaches this printf statement, unexpected_errno must evaluate to
false.
The true branch (", unexpected errno") can never be executed, preventing the
unexpected errno from being reported in the summary as intended.
> + fflush(stdout);
> + }
> +
> + SCX_FAIL_IF(failures == RELOAD_ITERS * RELOAD_THREADS,
> + "every attach failed");
>
> return SCX_TEST_PASS;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009134104.296891-1-cui.tao@linux.dev?part=5
prev parent reply other threads:[~2026-10-09 13:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 13:40 [PATCH 0/5] sched_ext: selftest infrastructure fixes Tao Cui
2026-10-09 13:41 ` [PATCH 1/5] selftests/sched_ext: Fix reload_loop error-path use-after-free Tao Cui
2026-10-09 13:41 ` [PATCH 2/5] sched_ext: Add SCX_ECODE_RSN_CGROUP_OFFLINE to user_exit_info.h Tao Cui
2026-10-09 13:41 ` [PATCH 3/5] selftests/sched_ext: Fail loudly when EXIT_KIND is missing from BTF Tao Cui
2026-10-09 13:54 ` sashiko-bot
2026-10-09 13:41 ` [PATCH 4/5] selftests/sched_ext: Add SCX_ASSERT_ALIVE and adopt it Tao Cui
2026-10-09 13:41 ` [PATCH 5/5] selftests/sched_ext: Bound exit waits and report reload_loop failures Tao Cui
2026-10-09 13:48 ` sashiko-bot [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-165673@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cui.tao@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sched-ext@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox