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 06/12] sched_ext: Fix proxy-exec race in consume_remote_task()
Date: Tue, 21 Jul 2026 07:51:28 +0000	[thread overview]
Message-ID: <20260721075129.2DB1F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260721063242.552774-7-arighi@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] task_can_move_from_locked_rq() fails to check if the task is the active donor on the source runqueue under proxy execution.
--

--- Patch [6]: [PATCH 06/12] sched_ext: Fix proxy-exec race in consume_remote_task() ---
commit 681e47b7800ef6cd6756031dfb833542e391c7df
Author: Andrea Righi <arighi@nvidia.com>

sched_ext: Fix proxy-exec race in consume_remote_task()

This patch addresses a proxy execution race where a task's state can change
without clearing holding_cpu. It introduces task_can_move_from_locked_rq()
to recheck the on-CPU and migration-disabled states after switching to the
source runqueue lock. If the state changed, the task is requeued on the
global DSQ instead of aborting the BPF scheduler.

> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 30d5965d09108..b5fd91d9bca4f 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c

[ ... ]

> @@ -2432,6 +2429,28 @@ 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.
> + */
> +static bool task_can_move_from_locked_rq(struct task_struct *p)
> +{
> +	struct rq *src_rq = task_rq(p);
> +
> +	lockdep_assert_rq_held(src_rq);
> +
> +	if (!sched_proxy_exec())
> +		return true;
> +
> +	/* @p may be rq->curr under another task's proxy scheduling context. */
> +	if (task_on_cpu(src_rq, p))
> +		return false;
> +

[Severity: High]
Is it possible for the active scheduling context (the donor) to be migrated
here?

When a task blocks on a mutex and becomes a proxy donor, it is retained on
the runqueue (p->on_rq == 1) without being dequeued. put_prev_task_scx()
sees SCX_TASK_QUEUED and enqueues this blocked task onto a DSQ.

When another CPU attempts to consume from this DSQ, consume_remote_task()
invokes this new task_can_move_from_locked_rq(). Since the donor is
blocked, task_on_cpu(src_rq, p) evaluates to false.

Without a check for task_current_donor(src_rq, p), could this return true
and allow move_remote_task_to_local_dsq() to migrate the active donor,
corrupting the proxy execution PI chain?

> +	return !is_migration_disabled(p);
> +}

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

  parent reply	other threads:[~2026-07-21  7:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  6:31 [PATCHSET v8 sched_ext/for-7.3] sched: Make proxy execution compatible with sched_ext Andrea Righi
2026-07-21  6:31 ` [PATCH 01/12] sched/core: Avoid false migration warning for proxy donors Andrea Righi
2026-07-21  6:50   ` sashiko-bot
2026-07-21  7:00   ` John Stultz
2026-07-21  7:34     ` Andrea Righi
2026-07-21  6:31 ` [PATCH 02/12] sched: Make NOHZ CFS bandwidth checks follow proxy donor Andrea Righi
2026-07-21  7:13   ` sashiko-bot
2026-07-21  6:31 ` [PATCH 03/12] sched: Add helper to block retained proxy donors Andrea Righi
2026-07-21  7:02   ` John Stultz
2026-07-21  6:31 ` [PATCH 04/12] sched_ext: Block proxy donors across scheduler transitions Andrea Righi
2026-07-21  6:31 ` [PATCH 05/12] sched_ext: Fix ops.running/stopping() pairing for proxy-exec donors Andrea Righi
2026-07-21  6:31 ` [PATCH 06/12] sched_ext: Fix proxy-exec race in consume_remote_task() Andrea Righi
2026-07-21  7:09   ` John Stultz
2026-07-21  7:51   ` sashiko-bot [this message]
2026-07-21  6:31 ` [PATCH 07/12] sched_ext: Split curr|donor references properly Andrea Righi
2026-07-21  8:13   ` sashiko-bot
2026-07-21  6:31 ` [PATCH 08/12] sched_ext: Handle blocked donor migration with proxy execution Andrea Righi
2026-07-21  8:42   ` sashiko-bot
2026-07-21  6:31 ` [PATCH 09/12] sched_ext: Delegate proxy donor admission to BPF schedulers Andrea Righi
2026-07-21  6:31 ` [PATCH 10/12] sched_ext: Add selftest for blocked donor admission Andrea Righi
2026-07-21  6:31 ` [PATCH 11/12] sched_ext: scx_qmap: Add proxy execution support Andrea Righi
2026-07-21  6:31 ` [PATCH 12/12] sched: Allow enabling proxy exec with sched_ext Andrea Righi
2026-07-21  7:05   ` John Stultz

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=20260721075129.2DB1F1F000E9@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.