All of lore.kernel.org
 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 10/15] sched_ext: Handle proxy-exec races in remote DSQ transfers
Date: Mon, 10 Aug 2026 16:04:38 +0000	[thread overview]
Message-ID: <20260810160439.3B4341F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810151523.86994-11-arighi@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Tasks can be permanently starved because migration-disabled state is conflated with active proxy execution, bypassing deferred work and BPF scheduler failsafes.
--

--- Patch [10]: [PATCH 10/15] sched_ext: Handle proxy-exec races in remote DSQ transfers ---
commit 4a7a0caa08e0bdff136179deb5a687b13392995f
Author: Andrea Righi <arighi@nvidia.com>

sched_ext: Handle proxy-exec races in remote DSQ transfers

This commit handles proxy execution races during remote DSQ transfers
by re-evaluating task execution and migration-disabled states under the
source rq lock. Tasks that can no longer proceed are parked on the
source rq's reject DSQ to be re-enqueued later, maintaining placement
policies.

> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index b43b2834141e6..7b467b666212b 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c

[ ... ]

> @@ -2573,6 +2585,60 @@ static bool task_can_run_on_remote_rq(struct scx_sched *sch,
>  	return true;
>  }
>  
> +/*
> + * Proxy execution can change @p's execution and migration-disabled state
> + * without touching its DSQ entry or clearing holding_cpu. Check those states
> + * with @p's rq locked. Without proxy execution, the holding_cpu handshake is
> + * sufficient and this must not affect the existing migration path.
> + *
> + * A BPF-directed transfer to a remote local DSQ performs a normal task
> + * migration and thus cannot move a migration-disabled task. In contrast,
> + * proxy_migrate_task() moves only a blocked donor's scheduling context towards
> + * the mutex owner and preserves its execution home in wake_cpu. The latter is
> + * therefore allowed even when the donor is migration-disabled.
> + */
> +static bool task_move_proxy_raced(struct task_struct *p)
> +{
> +	struct rq *src_rq = task_rq(p);
> +
> +	lockdep_assert_rq_held(src_rq);
> +
> +	if (!sched_proxy_exec())
> +		return false;
> +
> +	/* @p may be rq->curr under another task's scheduling context. */
> +	if (task_on_cpu(src_rq, p))
> +		return true;
> +
> +	if (is_migration_disabled(p))
> +		return true;

[Severity: High]
Does returning true unconditionally for migration-disabled tasks conflate them
with active proxy execution? 

If a task is migration-disabled but not actively proxying, it will be rejected
with SCX_TASK_REENQ_PROXY. Since rq_owned_post_enq() skips calling
schedule_deferred_locked() for SCX_TASK_REENQ_PROXY rejects:

	if (dsq->id == SCX_DSQ_REJECT) {
		if ((p->scx.flags & SCX_TASK_REENQ_REASON_MASK) ==
		    SCX_TASK_REENQ_PROXY)
			rq->scx.flags |= SCX_RQ_PROXY_REENQ;
		else
			schedule_deferred_locked(rq);
	}

And scx_proxy_resolved() is never called for a task that isn't actively
proxying, could this leave the task permanently stranded on the reject DSQ if
the source rq is idle?

> +
> +	/* Don't move an active scheduling context off its source rq. */
> +	if (task_current_donor(src_rq, p))
> +		return true;
> +
> +	return false;
> +}

[ ... ]

> @@ -2660,6 +2740,7 @@ static struct rq *move_task_between_dsqs(struct scx_sched *sch,
>  					 struct scx_dispatch_q *dst_dsq)
>  {
>  	struct rq *src_rq = task_rq(p), *dst_rq;
> +	bool proxy_raced;
>  
>  	BUG_ON(src_dsq->id == SCX_DSQ_LOCAL);
>  	lockdep_assert_held(&src_dsq->lock);
> @@ -2667,6 +2748,13 @@ static struct rq *move_task_between_dsqs(struct scx_sched *sch,
>  
>  	if (dst_dsq->id == SCX_DSQ_LOCAL) {
>  		dst_rq = container_of(dst_dsq, struct rq, scx.local_dsq);
> +		proxy_raced = src_rq != dst_rq && task_move_proxy_raced(p);
> +		if (unlikely(proxy_raced)) {
> +			dispatch_dequeue_locked(p, src_dsq);
> +			raw_spin_unlock(&src_dsq->lock);
> +			scx_reject_task(sch, src_rq, p, enq_flags);
> +			return src_rq;
> +		}

[Severity: High]
If a BPF scheduler incorrectly attempts to migrate a migration-disabled task to
a remote local DSQ, task_move_proxy_raced() intercepts the dispatch here.

Can this prevent task_can_run_on_remote_rq() from detecting the illegal
migration and triggering scx_error(), bypassing the BPF scheduler failsafe
while leaving the task permanently starved?

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

  reply	other threads:[~2026-08-10 16:04 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 15:13 [PATCHSET v11 sched_ext/for-7.3] sched: Make proxy execution compatible with sched_ext Andrea Righi
2026-08-10 15:13 ` [PATCH 01/15] sched: Make NOHZ CFS bandwidth checks follow proxy donor Andrea Righi
2026-08-10 15:35   ` sashiko-bot
2026-08-10 15:13 ` [PATCH 02/15] sched/core: Avoid false migration warning for proxy donors Andrea Righi
2026-08-10 15:13 ` [PATCH 03/15] sched: Pass next class to sched_change_begin() Andrea Righi
2026-08-10 15:13 ` [PATCH 04/15] sched: Add helper to block retained proxy donors Andrea Righi
2026-08-10 15:13 ` [PATCH 05/15] sched: Add sched_ext hooks for proxy execution Andrea Righi
2026-08-10 15:13 ` [PATCH 06/15] sched_ext: Block proxy donors across scheduler transitions Andrea Righi
2026-08-10 15:13 ` [PATCH 07/15] sched_ext: Fix ops.running/stopping() pairing for proxy-exec donors Andrea Righi
2026-08-10 15:13 ` [PATCH 08/15] sched_ext: Move reject DSQ draining into core Andrea Righi
2026-08-10 15:13 ` [PATCH 09/15] sched_ext: Generalize the reject DSQ reenqueue path Andrea Righi
2026-08-10 15:55   ` sashiko-bot
2026-08-10 15:13 ` [PATCH 10/15] sched_ext: Handle proxy-exec races in remote DSQ transfers Andrea Righi
2026-08-10 16:04   ` sashiko-bot [this message]
2026-08-10 15:13 ` [PATCH 11/15] sched_ext: Split curr|donor references properly Andrea Righi
2026-08-10 16:06   ` sashiko-bot
2026-08-10 15:13 ` [PATCH 12/15] sched_ext: Delegate proxy donor admission to BPF schedulers Andrea Righi
2026-08-10 15:13 ` [PATCH 13/15] sched_ext: Add selftest for blocked donor admission Andrea Righi
2026-08-10 15:14 ` [PATCH 14/15] sched_ext: scx_qmap: Add proxy execution support Andrea Righi
2026-08-10 15:14 ` [PATCH 15/15] sched: Allow enabling proxy exec with sched_ext Andrea Righi
  -- strict thread matches above, loose matches on Subject: below --
2026-07-28 15:43 [PATCHSET v10 sched_ext/for-7.3] sched: Make proxy execution compatible " Andrea Righi
2026-07-28 15:43 ` [PATCH 10/15] sched_ext: Handle proxy-exec races in remote DSQ transfers Andrea Righi
2026-08-03 21:36   ` Tejun Heo
2026-08-05 16:44     ` 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=20260810160439.3B4341F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.