The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	sched-ext@lists.linux.dev, Emil Tsalapatis <emil@etsalapatis.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 08/12] sched_ext: Add bandwidth-limited rescue execution for stranded tasks
Date: Mon, 3 Aug 2026 10:10:41 +0200	[thread overview]
Message-ID: <anBNAQ_dZ268Ekba@gpd4> (raw)
In-Reply-To: <20260802215447.3134509-9-tj@kernel.org>

Hi Tejun,

On Sun, Aug 02, 2026 at 11:54:43AM -1000, Tejun Heo wrote:
> A local DSQ insert lacking the needed caps is diverted to the reject DSQ and
> bounced back through ops.enqueue() so the scheduler can re-decide. That
> recovery assumes the scheduler has somewhere legal to send the task. When it
> doesn't, e.g. when the task's affinity is restricted to cids delegated away,
> the task starves until the stall watchdog ejects the scheduler. An exiting
> task is worse - it skips ops.enqueue() and the rejection becomes a
> self-requeuing cycle that burns the CPU until the watchdog fires.
> 
> Add SCX_ENQ_RESCUE, a fallback modifier on local DSQ inserts. When the
> insert would be rejected for missing caps, the kernel takes over and runs
> the task on the target CPU without consulting the owning scheduler. The
> kernel sets the flag itself when enqueueing an exiting task.
> 
> Rescue is a last-resort forward-progress backstop with a persistent
> disadvantage, not a way around cap enforcement. A per-CPU token bucket
> accrues rescue_bandwidth_ppt (default 2%) of CPU time and rescues run one at
> a time in arrival order. Each is granted a slice of the rescue_quantum_us
> (default 5ms) quantum divided across the waiters, waits at the tail of the
> local DSQ claiming no priority, and rejoins its scheduler as a fresh arrival
> once the slice is served.
> 
> The schedulers keep their normal control over an admitted rescuee and may
> preempt or reslice it. Service is measured on CPU time actually received, so
> neither shortens the rescue. Prolonged denial escalates - the remaining
> slice turns into protected execution (SCX_TASK_PROTECTED) and the rescuee
> preempts the current task. Escalation is paced by the same bucket, and
> delivered service converges on the configured bandwidth no matter how
> aggressively the schedulers dispatch.
> 
> Both knobs are root-only and SCX_RESCUE_DISABLE turns rescue off, making
> SCX_ENQ_RESCUE inserts reject as usual.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---
...
> diff --git a/kernel/sched/ext/internal.h b/kernel/sched/ext/internal.h
> index d418935f1e6b..18983dbe81f4 100644
> --- a/kernel/sched/ext/internal.h
> +++ b/kernel/sched/ext/internal.h
> @@ -924,6 +924,37 @@ struct sched_ext_ops {
>  	 */
>  	u32 cid_shard_size;
>  
> +	/**
> +	 * @rescue_bandwidth_ppt: Rescue execution bandwidth in parts per thousand
> +	 *
> +	 * The fraction of each CPU's time that may be consumed running tasks
> +	 * from its rescue DSQ. A higher bandwidth admits and escalates rescues
> +	 * faster, see @rescue_quantum_us.
> +	 *
> +	 * Only the root scheduler's value is used. 0 means the default of 20
> +	 * (2%). May not exceed 250 (25%). %SCX_RESCUE_DISABLE disables rescue -
> +	 * %SCX_ENQ_RESCUE inserts are then rejected like any other insert
> +	 * lacking the caps.
> +	 */
> +	u32 rescue_bandwidth_ppt;
> +
> +	/**
> +	 * @rescue_quantum_us: Rescue execution quantum in microseconds
> +	 *
> +	 * How much CPU time each rescue gets. Rescues run one at a time per CPU
> +	 * and admissions are paced to keep rescue execution within
> +	 * @rescue_bandwidth_ppt - with the defaults, one 5ms rescue every
> +	 * 250ms. A crowded queue round-robins on the quantum divided across the
> +	 * waiters, floored at 1ms. A stuck rescue eventually escalates to
> +	 * forced execution. A larger quantum interrupts the CPU less often but
> +	 * for longer and spaces rescues further apart.
> +	 *
> +	 * Only the root scheduler's value is used. 0 means the default (5000).
> +	 * Non-zero values must be within [1000, 100000]. Values too short for
> +	 * the kernel to meter are lifted silently.
> +	 */
> +	u32 rescue_quantum_us;
> +

Not a blocker, but should we add compatibility handling for these two optional
ops fields in tools/sched_ext/include/scx/compat.h?

Otherwise the later scx_qmap patch would break the qmap build with older
kernels.

Thanks,
-Andrea

  reply	other threads:[~2026-08-03  8:10 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 01/12] sched_ext: Rename scx_local_or_reject_dsq() to scx_resolve_local_dsq() Tejun Heo
2026-08-02 21:54 ` [PATCH 02/12] sched_ext: Make several ext.c helpers available outside ext.c Tejun Heo
2026-08-02 21:54 ` [PATCH 03/12] sched_ext: Factor out __scx_bpf_now() Tejun Heo
2026-08-02 21:54 ` [PATCH 04/12] sched_ext: Reject internal enq_flags in the dsq move kfuncs Tejun Heo
2026-08-02 21:54 ` [PATCH 05/12] sched_ext: Make SCX_ENQ_IGNORE_CAPS waive the preemption cap too Tejun Heo
2026-08-02 21:54 ` [PATCH 06/12] sched_ext: Synchronize slice and dsq_vtime writes Tejun Heo
2026-08-02 21:54 ` [PATCH 07/12] sched_ext: Add SCX_TASK_PROTECTED Tejun Heo
2026-08-02 21:54 ` [PATCH 08/12] sched_ext: Add bandwidth-limited rescue execution for stranded tasks Tejun Heo
2026-08-03  8:10   ` Andrea Righi [this message]
2026-08-03 18:59   ` [PATCH v2 " Tejun Heo
2026-08-02 21:54 ` [PATCH 09/12] sched_ext: Eject the top rescue consumer on overload Tejun Heo
2026-08-02 21:54 ` [PATCH 10/12] sched_ext: Sync tools autogen enum headers Tejun Heo
2026-08-02 21:54 ` [PATCH 11/12] sched_ext: scx_qmap - Idle-check pinned tasks before direct dispatch Tejun Heo
2026-08-02 21:54 ` [PATCH 12/12] sched_ext: scx_qmap - Add rescue support Tejun Heo
2026-08-03 20:42 ` [PATCHSET v2 sched_ext/for-7.3] sched_ext: Bandwidth-limited rescue execution for stranded tasks Andrea Righi
2026-08-03 21:37 ` Tejun Heo
  -- strict thread matches above, loose matches on Subject: below --
2026-08-01  8:51 [PATCHSET " Tejun Heo
2026-08-01  8:51 ` [PATCH 08/12] sched_ext: Add bandwidth-limited " 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=anBNAQ_dZ268Ekba@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=emil@etsalapatis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /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