Sched_ext development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Andrea Righi" <arighi@nvidia.com>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests
Date: Mon, 14 Sep 2026 14:59:25 +0000	[thread overview]
Message-ID: <20260914145925.E49B91F008A7@smtp.kernel.org> (raw)
In-Reply-To: <20260914144620.2032614-3-arighi@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The ENQ_BOTH scenario in the `kick` selftest hangs indefinitely on single-CPU systems due to starvation of the main test process.
--

commit 54a68e6d559e121241b4e1714f59dcb8d2d45246
Author: Andrea Righi <arighi@nvidia.com>

selftests/sched_ext: Add lazy preemption tests

This commit adds trace-based coverage for immediate and lazy preemption.
It exercises kick requests individually and combined, and extends the
NO_HZ_FULL test with infinite-slice victims.

> diff --git a/tools/testing/selftests/sched_ext/kick.bpf.c b/tools/testing/selftests/sched_ext/kick.bpf.c
> new file mode 100644
> index 0000000000000..03ddc44faf5c4
> --- /dev/null
> +++ b/tools/testing/selftests/sched_ext/kick.bpf.c
[ ... ]
> +void BPF_STRUCT_OPS(kick_enqueue, struct task_struct *p, u64 enq_flags)
> +{
> +	switch (scenario) {
> +	case ENQ_BOTH:
> +		if (p->pid == victim_pid) {
> +			scx_bpf_dsq_insert(p, SCX_DSQ_GLOBAL, SCX_SLICE_INF,
> +					   enq_flags);
[Severity: Medium]
Will this assignment of SCX_SLICE_INF to the victim task starve the main
test process and hang the test indefinitely on single-CPU systems?

When the main test process shares the CPU with the victim, its usleep()
timer wakeup inadvertently consumes the KICK_STATE_QUEUED state, advancing
the test state to KICK_STATE_DONE. When it sleeps again inside
wait_for_state(), it is awoken but enqueued into the global DSQ without
preemption flags (since the state is no longer QUEUED). Because the victim
task runs with SCX_SLICE_INF, it is never preempted by the tick, starving
the main test process forever.

> +		} else if (state == KICK_STATE_QUEUED) {
> +			scx_bpf_dsq_insert(p, SCX_DSQ_LOCAL, SCX_SLICE_DFL,
> +					   enq_flags | SCX_ENQ_PREEMPT |
> +					   SCX_ENQ_PREEMPT_LAZY);
> +		} else {
[ ... ]
> diff --git a/tools/testing/selftests/sched_ext/kick.c b/tools/testing/selftests/sched_ext/kick.c
> new file mode 100644
> index 0000000000000..b7af2683c2728
> --- /dev/null
> +++ b/tools/testing/selftests/sched_ext/kick.c
[ ... ]
> +static enum scx_test_status trace_one(u32 scenario, u64 ops_flags,
> +				      s32 slice_expiry_override,
> +				      struct observation *obs)
> +{
> +	struct bpf_link *ops_link = NULL;
> +	struct kick *skel = NULL;
> +	struct victim challenger = { .pid = -1, .start_fd = -1 };
> +	struct victim victim;
> +	enum scx_test_status ret = SCX_TEST_FAIL;
> +	int cpu = pick_target_cpu();
[Severity: Medium]
Should we migrate the main test process away from this target CPU, or skip
the test if a second housekeeping CPU is unavailable (similar to the
behavior in nohz_tick.c)?

If the main test process runs on the same CPU as the victim task, it can be
starved by the victim task receiving an infinite time slice during the
ENQ_BOTH scenario, causing the test to hang indefinitely.

> +
> +	if (cpu < 0) {
> +		SCX_ERR("No available CPU");
> +		return SCX_TEST_FAIL;
> +	}
> +	victim = spawn_victim(cpu);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260914144620.2032614-1-arighi@nvidia.com?part=2

  reply	other threads:[~2026-09-14 14:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 14:44 [PATCHSET v3 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-14 14:44 ` [PATCH 1/2] " Andrea Righi
2026-09-14 14:58   ` sashiko-bot
2026-09-14 14:44 ` [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests Andrea Righi
2026-09-14 14:59   ` sashiko-bot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-09-18 17:13 [PATCHSET v7 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-18 17:13 ` [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests Andrea Righi
2026-09-17  7:02 [PATCHSET v6 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-17  7:02 ` [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests Andrea Righi
2026-09-17 19:19   ` Tejun Heo
2026-09-18  6:30     ` Andrea Righi
2026-09-15 19:45 [PATCHSET v5 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-15 19:45 ` [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests Andrea Righi
2026-09-16 21:03   ` Tejun Heo
2026-09-15  9:00 [PATCHSET v4 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-15  9:00 ` [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests Andrea Righi
2026-09-14  8:47 [PATCHSET v2 sched_ext/for-7.4] sched_ext: Add lazy preemption support Andrea Righi
2026-09-14  8:47 ` [PATCH 2/2] selftests/sched_ext: Add lazy preemption tests Andrea Righi
2026-09-14  9:01   ` sashiko-bot
2026-09-14 12:21     ` Andrea Righi
2026-09-14 14:55   ` Cheng-Yang Chou
2026-09-15 13:35     ` Andrea Righi

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=20260914145925.E49B91F008A7@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arighi@nvidia.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