Sched_ext development
 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/11] sched_ext: Split curr|donor references properly
Date: Wed, 15 Jul 2026 21:15:58 +0000	[thread overview]
Message-ID: <20260715211558.E20D01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715205622.276220-7-arighi@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incomplete migration from rq->curr to rq->donor for proxy execution breaks capability revocation, preemption checks, and BPF kfuncs.
--

--- Patch [6]: [PATCH 06/11] sched_ext: Split curr|donor references properly ---
commit 8ca59038e09f66e910a65ddcaf538ce84385abf5
Author: Andrea Righi <arighi@nvidia.com>

sched_ext: Split curr|donor references properly

This commit updates sched_ext to use rq->donor instead of rq->curr where
appropriate to correctly handle proxy execution. This ensures that the
scheduler-selected task (donor) supplies the scheduling context and budget,
even when a different task physically executes on the CPU.

> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 8d8057b80d544..0d2f34c79083f 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c

[ ... ]

> @@ -8030,7 +8049,7 @@ static bool kick_one_cpu(s32 cpu, struct scx_sched_pcpu *pcpu, struct rq *this_r
>  	unsigned long flags;
>  
>  	raw_spin_rq_lock_irqsave(rq, flags);
> -	cur_class = rq->curr->sched_class;
> +	cur_class = rq->donor->sched_class;
>  
>  	/*
>  	 * During CPU hotplug, a CPU may depend on kicking itself to make
> @@ -8047,7 +8066,7 @@ static bool kick_one_cpu(s32 cpu, struct scx_sched_pcpu *pcpu, struct rq *this_r
>  			if (cur_class == &ext_sched_class) {
>  				if (likely(!scx_missing_caps(pcpu->sch, cpu,
>  							     scx_caps_for_preempt(pcpu->sch, rq))))
> -					set_task_slice(rq->curr, 0);
> +					set_task_slice(rq->donor, 0);
>  				else
>  					__scx_add_event(pcpu->sch,
>  							SCX_EV_SUB_PREEMPT_DENIED, 1);

[Severity: High]
Should this migration from rq->curr to rq->donor also be applied to other
functions that interact with the scheduling context?

For example, in reenq_local(), capability revocation eviction appears to check
the physical lock owner instead of the proxy donor:

kernel/sched/ext/ext.c:reenq_local() {
...
	if ((reenq_flags & SCX_REENQ_CAP_REVOKE) &&
	    rq->curr->sched_class == &ext_sched_class &&
	    scx_task_reenq_on_cap_revoke(rq, rq->curr)) {
		set_task_slice(rq->curr, 0);
...
}

Could this cause capability revocation to fail for proxy donors executing
on behalf of non-EXT tasks?

Similarly, scx_caps_for_preempt() evaluates capabilities against the physical
lock owner:

kernel/sched/ext/sub.h:scx_caps_for_preempt() {
	struct task_struct *curr = rq->curr;
...
	if (curr->sched_class != &ext_sched_class ||
...
}

Could this allow unauthorized preemption if the proxy donor is an EXT task
but the physical lock owner is a non-EXT task?

Additionally, BPF kfuncs scx_bpf_task_running() and scx_bpf_cpu_curr() report
the physical owner instead of the expected scheduling context:

kernel/sched/ext/ext.c:scx_bpf_task_running() {
	return task_rq(p)->curr == p;
}

kernel/sched/ext/ext.c:scx_bpf_cpu_curr() {
	return rcu_dereference(cpu_rq(cpu)->curr);
}

Does this expose the physical lock owner instead of the proxy donor context,
potentially confusing the BPF scheduler which expects to see the EXT task it
dispatched?

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

  reply	other threads:[~2026-07-15 21:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15 20:54 [PATCHSET v6 sched_ext/for-7.3] sched: Make proxy execution compatible with sched_ext Andrea Righi
2026-07-15 20:54 ` [PATCH 01/11] sched: Make NOHZ CFS bandwidth checks follow proxy donor Andrea Righi
2026-07-15 20:54 ` [PATCH 02/11] sched: Add helper to block retained proxy donors Andrea Righi
2026-07-15 20:54 ` [PATCH 03/11] sched_ext: Block proxy donors across scheduler transitions Andrea Righi
2026-07-15 20:54 ` [PATCH 04/11] sched_ext: Fix ops.running/stopping() pairing for proxy-exec donors Andrea Righi
2026-07-15 20:54 ` [PATCH 05/11] sched_ext: Fix TOCTOU race in consume_remote_task() Andrea Righi
2026-07-15 21:14   ` sashiko-bot
2026-07-15 20:54 ` [PATCH 06/11] sched_ext: Split curr|donor references properly Andrea Righi
2026-07-15 21:15   ` sashiko-bot [this message]
2026-07-15 20:54 ` [PATCH 07/11] sched_ext: Handle blocked donor migration with proxy execution Andrea Righi
2026-07-15 21:21   ` sashiko-bot
2026-07-15 20:54 ` [PATCH 08/11] sched_ext: Delegate proxy donor admission to BPF schedulers Andrea Righi
2026-07-15 20:54 ` [PATCH 09/11] sched_ext: Add selftest for blocked donor admission Andrea Righi
2026-07-15 20:54 ` [PATCH 10/11] sched_ext: scx_qmap: Add proxy execution support Andrea Righi
2026-07-15 21:35   ` sashiko-bot
2026-07-15 20:54 ` [PATCH 11/11] sched: Allow enabling proxy exec with sched_ext 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=20260715211558.E20D01F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox