mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: sched-ext@lists.linux.dev, David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	David Dai <david.dai@linux.dev>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 17/17] sched_ext: Fix queued bypassed tasks stalling when the host loses SCX_CAP_BASE
Date: Sun, 25 Oct 2026 16:47:03 +0100	[thread overview]
Message-ID: <at4kd-78BbpBX-_4@gpd4> (raw)
In-Reply-To: <20261023175608.4120910-18-tj@kernel.org>

Hi Tejun,

On Fri, Oct 23, 2026 at 07:56:08AM -1000, Tejun Heo wrote:
> A task already queued on a bypass DSQ stalls when the host loses
> SCX_CAP_BASE on that cpu. The cpu's dispatch no longer consumes the DSQ, and
> the task sits there until the host regains BASE or the bypass window ends.
> Sending a bypassed task to rescue at enqueue time covers only a task
> enqueued after the loss, and the balancer no longer donates to a capless
> cpu.
> 
> Have the bypass load balancer drain such a DSQ: a cpu where the host lacks
> BASE is a donor with a target of zero. The target already counts its tasks
> against the cpus that hold BASE, so the donees take them under their
> ordinary fill. The queued-duration threshold doesn't apply to a zero target.
> 
> The balancer reenqueues a task no donee can take at its home, under the home
> rq lock the move holds there anyway. The enqueue sends the task to rescue
> when the host lacks BASE at home and rescue is enabled, and to the home's
> bypass DSQ otherwise. A task that must run at home, migration-disabled or
> with a migration pending, is admitted to the home's local DSQ in either
> case. Every donee refuses a migration-disabled task, so it always takes this
> path.
> 
> The same reenqueue replaces the put-back for a task that can't run on the
> donee the walk picked for it. That is a cold path: the donee went inactive
> or the task is a proxy-migrated blocked donor. An affinity change while the
> move is in flight dequeues the task and the balancer loses the claim
> instead.
> 
> Without rescue, the reenqueue of a task homed on the drained cpu lands on
> the DSQ it came from, apart from the admit above. A task stuck that way is
> reenqueued once per pass and waits for the host to regain BASE or the bypass
> to end, or for the stall watchdog to eject the host, which it blames for a
> task stuck on its DSQ.
> 
> With a zero interval the stuck task is reenqueued once per BASE loss, and a
> task that lands on the drained DSQ after that pass waits the same way. These
> reenqueues, like those of a task refused pass after pass, are not counted
> against the reenqueue limit, as the task's scheduler is bypassing.
> 
> On a BASE loss, scx_bypass_lb_kick() sets the balancer's timer to expire
> now, so that the drain runs before the next interval, and runs at all when
> the interval is zero. A donee can lose BASE while the balancer is moving
> tasks onto it, and the kick from that loss covers it.
> 
> The balancer re-arms with timer_reduce(), which only brings the expiry
> forward, so a loss during a run leaves the timer at now and the next run
> sees it. The arming at bypass dispatch enable uses timer_reduce() too, so
> that a kick landing there is kept.
> 
> v2: The description drops an in-flight affinity change from the causes of a
> refused balancer move.
> 
> v3:
> - The description says that a stuck task's reenqueues are not counted
>   against the reenqueue limit (sashiko).
> - The description names the stall watchdog as the way out for a task stuck
>   without rescue, and the tasks a zero interval leaves on a drained DSQ.
> - bypass_lb_reenq_home()'s kerneldoc and the description give the placement
>   with rescue disabled and for a task that must run at home, and the other
>   two comments on that placement point to the kerneldoc.
> 
> Fixes: 147d1885f390 ("sched_ext: Add the SCX_CAP_ENQ_IMMED cap")
> Signed-off-by: Tejun Heo <tj@kernel.org>

...

> @@ -6579,20 +6602,21 @@ static s32 bypass_lb_move(struct scx_sched *sch, struct rq *donor_rq,
>  	/*
>  	 * @p's affinity is stable under its rq lock. A task whose donee is its
>  	 * own cpu can always run there, and task_can_run_on_remote_rq() warns
> -	 * when asked about a task's own cpu.
> +	 * when asked about a task's own cpu. A @donee of -1 means none, so
> +	 * don't pass it to cpu_rq().
>  	 */
> -	if (donee == task_cpu(p) || task_can_run_on_remote_rq(sch, p, cpu_rq(donee), false)) {
> -		dst_dsq = scx_bypass_dsq(sch, donee);
> -		enq_flags = 0;
> +	if (donee >= 0 && (donee == task_cpu(p) ||
> +			   task_can_run_on_remote_rq(sch, p, cpu_rq(donee), false))) {
> +		scx_dispatch_enqueue(sch, rq, scx_bypass_dsq(sch, donee), p, 0, 0, 0);
>  		ret = donee;
>  	} else {
> -		/* back where it was, at the head so that the walk skips it */
> -		dst_dsq = donor_dsq;
> -		enq_flags = SCX_ENQ_HEAD;
> -		ret = -1;
> +		/*
> +		 * No donee, or @p can't run on it. Reenqueue @p at home
> +		 * instead, see bypass_lb_reenq_home().
> +		 */
> +		bypass_lb_reenq_home(rq, p, cpu_of(donor_rq));
> +		ret = cpu_of(rq);

Not a blocker, but I was wondering if we should preserve the old head or
ordinary balancing when the donor still holds BASE?

If a selected donee refuses a task homed on the donor, this can put it
at the tail of the same DSQ. A proxy-migrated blocked donor is refused
by remote CPUs, so repeated balancing passes could keep pushing it back.

Thanks,
-Andrea

  reply	other threads:[~2026-10-25 15:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 17:55 [PATCHSET v3 sched_ext/for-7.4] sched_ext: Fix bypassed sub-scheduler tasks stalling when the host lacks caps Tejun Heo
2026-10-23 17:55 ` [PATCH 01/17] sched_ext: Pack scx_ent_flags' multi-bit fields at the top Tejun Heo
2026-10-23 17:55 ` [PATCH 02/17] sched_ext: Clear holding_cpu where the claim is confirmed Tejun Heo
2026-10-23 17:55 ` [PATCH 03/17] sched_ext: Fix bypassed tasks stranded by the reenqueue limit Tejun Heo
2026-10-23 17:55 ` [PATCH 04/17] sched_ext: Fix bypassed tasks looping on a host without SCX_CAP_ENQ Tejun Heo
2026-10-23 17:55 ` [PATCH 05/17] sched_ext: Move refill_task_slice_dfl() below apply_slice_vtime() Tejun Heo
2026-10-23 17:55 ` [PATCH 06/17] sched_ext: Fix rescue served time disagreeing with the slice under proxy execution Tejun Heo
2026-10-23 17:55 ` [PATCH 07/17] sched_ext: Restore a rescuee's slice after ops.stopping() Tejun Heo
2026-10-23 17:55 ` [PATCH 08/17] sched_ext: Fix a cpu idling with a runnable rescuee Tejun Heo
2026-10-23 17:56 ` [PATCH 09/17] sched_ext: Mark the rescue grant as a kernel slice with SCX_TASK_KERNEL_SLICE Tejun Heo
2026-10-23 17:56 ` [PATCH 10/17] sched_ext: Refuse extending a kernel slice Tejun Heo
2026-10-23 17:56 ` [PATCH 11/17] sched_ext: Fix a cpu idling after put_prev_task_scx() queues its task on the local DSQ Tejun Heo
2026-10-23 17:56 ` [PATCH 12/17] sched_ext: Expire prev's slice in dispatch_one() under bypass Tejun Heo
2026-10-23 17:56 ` [PATCH 13/17] sched_ext: Fix bypassed tasks stalling when the host lacks SCX_CAP_BASE Tejun Heo
2026-10-23 17:56 ` [PATCH 14/17] sched_ext: Fix the bypass load balancer stranding tasks on cpus where " Tejun Heo
2026-10-23 17:56 ` [PATCH 15/17] sched_ext: Factor out bypass_lb_move() and insert with the donor DSQ unlocked Tejun Heo
2026-10-23 17:56 ` [PATCH 16/17] sched_ext: Let the bypass load balancer move tasks homed on other cpus Tejun Heo
2026-10-23 17:56 ` [PATCH 17/17] sched_ext: Fix queued bypassed tasks stalling when the host loses SCX_CAP_BASE Tejun Heo
2026-10-25 15:47   ` Andrea Righi [this message]
2026-10-26 21:31     ` Tejun Heo
2026-10-23 20:06 ` [PATCH 18/17] sched_ext: Fix use-after-free of a NONE rescuee leaving sched_ext Tejun Heo
2026-10-23 20:06 ` [PATCH 19/17] sched_ext: Fix the stall watchdog blaming a bypassing owner for a stuck task Tejun Heo
2026-10-25 15:52   ` Andrea Righi
2026-10-26 21:31     ` Tejun Heo
2026-10-23 20:10 ` [PATCH 20/17] sched_ext: Fix a lone IMMED task waiting behind a kept prev 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=at4kd-78BbpBX-_4@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=david.dai@linux.dev \
    --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

all inboxes | Powered by JetHome®