Sched_ext development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tejun Heo" <tj@kernel.org>
Cc: sched-ext@lists.linux.dev
Subject: Re: [PATCH 09/12] sched_ext: Eject the top rescue consumer on overload
Date: Sat, 01 Aug 2026 09:11:14 +0000	[thread overview]
Message-ID: <20260801091115.750DC1F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260801085150.2697653-10-tj@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The `time_before()` check in `scx_rescue_check_overload()` suffers from a 32-bit jiffies wraparound vulnerability, disabling rescue overload protection for 24.8-day intervals on systems with 32-bit `unsigned long`.
--

--- Patch [9]: [PATCH 09/12] sched_ext: Eject the top rescue consumer on overload ---
commit 50e2ffc187a8450dacf680dcf11b98c2167b7621
Author: Tejun Heo <tj@kernel.org>

sched_ext: Eject the top rescue consumer on overload

This patch tracks each scheduler's recent rescue consumption per CPU as a
decaying average. If the oldest waiter on a CPU's rescue DSQ waits past a
configured threshold, the sub-scheduler with the highest recent consumption
is ejected. This prevents the generic stall watchdog from unfairly blaming
the waiting task's owner instead of the misbehaving party.

> diff --git a/kernel/sched/ext/sub.c b/kernel/sched/ext/sub.c
> index 3c1f11268e7f3..fdbe1c1bfaa8d 100644
> --- a/kernel/sched/ext/sub.c
> +++ b/kernel/sched/ext/sub.c

[ ... ]

> @@ -434,6 +459,63 @@ static bool scx_rescue_try_admit(struct rq *rq, struct task_struct *p)
>  	return false;
>  }
>  
> +/**
> + * scx_rescue_check_overload - Eject the top rescue consumer on a stuck rescue
> + * @rq: rq whose rescue timer fired
> + *
> + * If the oldest waiter on @rq's rescue DSQ has been queued for too long, rescue
> + * demand on this cpu persistently exceeds the configured bandwidth. Eject the
> + * sub with the highest recent rescue consumption instead of letting the
> + * scheduler stall path blame the waiter's owner, who may just be crowded out.
> + */
> +static void scx_rescue_check_overload(struct rq *rq)
> +{
> +	struct scx_sched *victim = NULL, *pos;
> +	struct task_struct *p;
> +	int cpu = cpu_of(rq);
> +	u64 max_avg = 0;
> +	u32 dur_ms;
> +
> +	lockdep_assert_rq_held(rq);
> +
> +	p = list_first_entry_or_null(&rq->scx.rescue.dsq.list, struct task_struct,
> +				     scx.dsq_list.node);
> +	if (!p)
> +		return;
> +
> +	/* has the head waiter been queued for longer than the threshold? */
> +	if (time_before(jiffies, p->scx.rescue_at + scx_rescue_overload_after))
> +		return;
> +
> +	/*
> +	 * Grace period after the last ejection on this cpu - the freed
> +	 * bandwidth gets one threshold's worth of time to drain the backlog
> +	 * before another sub is judged.
> +	 */
> +	if (time_before(jiffies, rq->scx.rescue.kill_at + scx_rescue_overload_after))
> +		return;

[Severity: Medium]
Does this time_before() check have an issue with jiffies wraparound on 32-bit
systems?

If no rescue ejection occurs for LONG_MAX jiffies (about 24.8 days at HZ=1000
on 32-bit systems), jiffies - rq->scx.rescue.kill_at will exceed LONG_MAX.
Because the time_before() macro uses signed arithmetic, the difference wraps
around to a negative value.

This causes time_before() to incorrectly evaluate to true, falsely trapping
the CPU in a continuous grace period. Would this disable overload ejections
for the next 24.8 days and cause the scheduler to fall back to the generic
stall watchdog instead?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260801085150.2697653-1-tj@kernel.org?part=9

  reply	other threads:[~2026-08-01  9:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01  8:51 [PATCHSET sched_ext/for-7.3] sched_ext: Bandwidth-limited rescue execution for stranded tasks Tejun Heo
2026-08-01  8:51 ` [PATCH 01/12] sched_ext: Rename scx_local_or_reject_dsq() to scx_resolve_local_dsq() Tejun Heo
2026-08-01  8:51 ` [PATCH 02/12] sched_ext: Make several ext.c helpers available outside ext.c Tejun Heo
2026-08-01  8:58   ` sashiko-bot
2026-08-01  8:51 ` [PATCH 03/12] sched_ext: Factor out __scx_bpf_now() Tejun Heo
2026-08-01  8:51 ` [PATCH 04/12] sched_ext: Reject internal enq_flags in the dsq move kfuncs Tejun Heo
2026-08-01  8:51 ` [PATCH 05/12] sched_ext: Make SCX_ENQ_IGNORE_CAPS waive the preemption cap too Tejun Heo
2026-08-01  8:51 ` [PATCH 06/12] sched_ext: Synchronize slice and dsq_vtime writes Tejun Heo
2026-08-01  8:51 ` [PATCH 07/12] sched_ext: Add SCX_TASK_PROTECTED Tejun Heo
2026-08-01  8:51 ` [PATCH 08/12] sched_ext: Add bandwidth-limited rescue execution for stranded tasks Tejun Heo
2026-08-01  8:51 ` [PATCH 09/12] sched_ext: Eject the top rescue consumer on overload Tejun Heo
2026-08-01  9:11   ` sashiko-bot [this message]
2026-08-01  8:51 ` [PATCH 10/12] sched_ext: Sync tools autogen enum headers Tejun Heo
2026-08-01  8:51 ` [PATCH 11/12] sched_ext: scx_qmap - Idle-check pinned tasks before direct dispatch Tejun Heo
2026-08-01  9:06   ` sashiko-bot
2026-08-01  8:51 ` [PATCH 12/12] sched_ext: scx_qmap - Add rescue support Tejun Heo
2026-08-01  9:06   ` sashiko-bot
2026-08-02 19:51     ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2026-08-02 21:54 [PATCHSET v2 sched_ext/for-7.3] sched_ext: Bandwidth-limited rescue execution for stranded tasks Tejun Heo
2026-08-02 21:54 ` [PATCH 09/12] sched_ext: Eject the top rescue consumer on overload Tejun Heo

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=20260801091115.750DC1F00AC4@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    /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