From: sashiko-bot@kernel.org
To: "Changwoo Min" <changwoo@igalia.com>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH v2 7/8] selftests/sched_ext: Test p->scx.bpf_priv across class changes
Date: Thu, 03 Dec 2026 05:26:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-247196@kernel.org> (raw)
In-Reply-To: <20261203045618.982539-8-changwoo@igalia.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] selftests/sched_ext: leak BPF skeleton on load or attach failure
in run()
- [Low] selftests/sched_ext: SCHED_FIFO fails with EPERM under
RT_GROUP_SCHED
- [Low] selftests/sched_ext: SCX_EQ() double-evaluates side-effecting
calls
--
commit 2808488ab5be9ddd62f306578e0441c81a3df090
Author: Changwoo Min <changwoo@igalia.com>
selftests/sched_ext: Test p->scx.bpf_priv across class changes
This commit adds the task_bpf_priv sched_ext selftest to verify that
p->scx.bpf_priv is set on ops.enable(), cleared on class changes and
scheduler unload, and not inherited across fork.
> diff --git a/tools/testing/selftests/sched_ext/task_bpf_priv.c b/tools/testing/selftests/sched_ext/task_bpf_priv.c
> new file mode 100644
> index 0000000000000..7500fc5a4992f
> --- /dev/null
> +++ b/tools/testing/selftests/sched_ext/task_bpf_priv.c
> @@ -0,0 +1,147 @@
[ ... ]
> + /* Step 1: Switch this task to SCHED_EXT */
> + SCX_EQ(set_policy(SCHED_EXT, 0), 0);
[Severity: Low]
Can passing set_policy(), probe(), and waitpid() directly to SCX_EQ()
execute them twice on failure?
SCX_EQ() in scx_test.h expands both arguments a second time when
formatting the error message. If waitpid() fails with EINTR, the second
call can reap the child and print equal values in the failure log.
Storing the return value in a local variable avoids double evaluation.
[ ... ]
> + /* Step 3: Switch this task to SCHED_FIFO */
> + SCX_EQ(set_policy(SCHED_FIFO, 1), 0);
[Severity: Low]
Will switching to SCHED_FIFO fail with EPERM under CONFIG_RT_GROUP_SCHED?
In a non-root cgroup v2 group (such as a systemd slice or container),
__sched_setscheduler() rejects SCHED_FIFO with EPERM even for root when
rt_runtime is 0, causing a false test failure.
Because task_bpf_priv_ops uses SCX_OPS_SWITCH_PARTIAL, switching to
SCHED_OTHER exercises the same switched_from_scx() disable and reset
path without requiring RT group bandwidth.
[ ... ]
> +static enum scx_test_status run(void *ctx)
> +{
> + enum scx_test_status status;
> + struct task_bpf_priv *skel;
> + struct bpf_link *link;
> +
> + skel = task_bpf_priv__open();
> + SCX_FAIL_IF(!skel, "Failed to open skel");
> + SCX_ENUM_INIT(skel);
> + SCX_FAIL_IF(task_bpf_priv__load(skel), "Failed to load skel");
> +
> + link = bpf_map__attach_struct_ops(skel->maps.task_bpf_priv_ops);
> + SCX_FAIL_IF(!link, "Failed to attach struct_ops");
> +
> + status = steps(skel, &link);
> +
> + /* Restore the policy even if a step failed */
> + set_policy(SCHED_OTHER, 0);
> + bpf_link__destroy(link);
> + task_bpf_priv__destroy(skel);
> +
> + return status;
> +}
[Severity: Low]
Does run() leak skel if task_bpf_priv__load() or
bpf_map__attach_struct_ops() fails?
SCX_FAIL_IF() returns SCX_TEST_FAIL directly, skipping
task_bpf_priv__destroy(skel). Since task_bpf_priv has no cleanup
callback and the runner executes all tests in one process, the skeleton
memory and loaded BPF file descriptors remain leaked for the rest of the
run.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203045618.982539-1-changwoo@igalia.com?part=7
next prev parent reply other threads:[~2026-12-03 5:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 4:56 [PATCH v2 0/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Changwoo Min
2026-12-03 4:56 ` [PATCH v2 1/8] sched_ext: Reset task fields after ops.exit_task() Changwoo Min
2026-12-04 6:10 ` Andrea Righi
2026-12-03 4:56 ` [PATCH v2 2/8] sched_ext: Mark a task enabled before ops.enable() Changwoo Min
2026-12-04 6:10 ` Andrea Righi
2026-12-03 4:56 ` [PATCH v2 3/8] sched_ext: Add scx_bpf_sched_id() and scx_bpf_task_sched_id() Changwoo Min
2026-12-03 5:14 ` sashiko-bot
2026-12-04 6:44 ` Andrea Righi
2026-12-03 4:56 ` [PATCH v2 4/8] selftests/sched_ext: Test " Changwoo Min
2026-12-03 5:14 ` sashiko-bot
2026-12-03 4:56 ` [PATCH v2 5/8] sched_ext: Add p->scx.bpf_priv for O(1) task context lookup Changwoo Min
2026-12-03 5:20 ` sashiko-bot
2026-12-03 4:56 ` [PATCH v2 6/8] sched_ext: scx_qmap: Cache task_ctx in p->scx.bpf_priv Changwoo Min
2026-12-03 5:19 ` sashiko-bot
2026-12-03 4:56 ` [PATCH v2 7/8] selftests/sched_ext: Test p->scx.bpf_priv across class changes Changwoo Min
2026-12-03 5:26 ` sashiko-bot [this message]
2026-12-03 4:56 ` [PATCH v2 8/8] selftests/sched_ext: Test task field reset across sub-scheduler handoffs Changwoo Min
2026-12-03 5:32 ` sashiko-bot
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-247196@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=changwoo@igalia.com \
--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