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: Thu, 16 Jul 2026 15:02:51 +0000	[thread overview]
Message-ID: <20260716150252.68BAD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260716132229.61603-7-arighi@nvidia.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing TICK_DEP_BIT_SCHED protection for cross-class proxy execution causes remote NOHZ tick warnings and accounting corruption.
- [Medium] The ops.running() callback is never invoked for the physical lock owner under proxy execution, violating the documented API contract.
--

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

sched_ext: Split curr|donor references properly

This commit prepares sched_ext for proxy execution by differentiating
between the scheduling context provider (rq->donor) and the physically
executing task (rq->curr). It adjusts tick management, task selection,
and BPF helper functions to use the donor where appropriate.

> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c

[ ... ]

> @@ -4370,14 +4381,14 @@ static void run_deferred(struct rq *rq)
>  #ifdef CONFIG_NO_HZ_FULL
>  bool scx_can_stop_tick(struct rq *rq)
>  {
> -	struct task_struct *p = rq->curr;
> +	struct task_struct *p = rq->donor;
>  	struct scx_sched *sch = scx_task_sched(p);
>  
>  	if (p->sched_class != &ext_sched_class)
>  		return true;

[Severity: High]
Does this missing check cause remote NOHZ tick warnings during cross-class
proxy execution?

If a FAIR task donates to an EXT task, rq->donor is FAIR but rq->curr is
EXT. When scx_can_stop_tick() is called, it checks p->sched_class (which
is FAIR) and immediately returns true. If the FAIR donor isn't bandwidth
constrained, this allows the tick to stop.

However, stopping the tick when rq->curr != rq->donor violates core NOHZ
assumptions and triggers a WARN_ON_ONCE in sched_tick_remote().

Will this also corrupt time bandwidth accounting by charging the EXT owner
instead of the FAIR donor?

[ ... ]

> @@ -9932,10 +9955,14 @@ __bpf_kfunc struct rq *scx_bpf_locked_rq(const struct bpf_prog_aux *aux)
>  }
>  
>  /**
> - * scx_bpf_cpu_curr - Return remote CPU's curr task
> + * scx_bpf_cpu_curr - Return remote CPU's current scheduling context
>   * @cpu: CPU of interest
>   * @aux: implicit BPF argument to access bpf_prog_aux hidden from BPF progs
>   *
> + * Under proxy execution, this returns the donor, which supplies the scheduling
> + * policy and runtime budget, rather than the task whose code is physically
> + * executing. ops.running() continues to report physical task execution.
> + *

[Severity: Medium]
Is ops.running() actually invoked for the physical lock owner as documented
here?

When a task donates its context, the core scheduler calls
set_next_task_scx() for the blocked donor. However, set_next_task_scx()
explicitly skips ops.running() for blocked tasks:

set_next_task_scx() {
    ...
    if ((p->scx.flags & SCX_TASK_QUEUED) && !p->is_blocked) {
        if (SCX_HAS_OP(sch, running))
            SCX_CALL_OP_TASK(sch, running, rq, p);
    }
    ...
}

Since the core scheduler context-switches to the physical lock owner
without invoking its scheduling class callbacks, does this leave the BPF
scheduler completely blind to the physical task execution?

>   * Callers must hold RCU read lock (KF_RCU).
>   */
>  __bpf_kfunc struct task_struct *scx_bpf_cpu_curr(s32 cpu, const struct bpf_prog_aux *aux)

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

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

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 13:20 [PATCHSET v7 sched_ext/for-7.3] sched: Make proxy execution compatible with sched_ext Andrea Righi
2026-07-16 13:20 ` [PATCH 01/11] sched: Make NOHZ CFS bandwidth checks follow proxy donor Andrea Righi
2026-07-18  3:11   ` John Stultz
2026-07-16 13:20 ` [PATCH 02/11] sched: Add helper to block retained proxy donors Andrea Righi
2026-07-16 13:20 ` [PATCH 03/11] sched_ext: Block proxy donors across scheduler transitions Andrea Righi
2026-07-18  3:16   ` John Stultz
2026-07-16 13:20 ` [PATCH 04/11] sched_ext: Fix ops.running/stopping() pairing for proxy-exec donors Andrea Righi
2026-07-16 13:20 ` [PATCH 05/11] sched_ext: Fix TOCTOU race in consume_remote_task() Andrea Righi
2026-07-16 14:39   ` sashiko-bot
2026-07-16 21:29   ` Tejun Heo
2026-07-16 21:38     ` Tejun Heo
2026-07-17  6:35       ` Andrea Righi
2026-07-16 13:20 ` [PATCH 06/11] sched_ext: Split curr|donor references properly Andrea Righi
2026-07-16 15:02   ` sashiko-bot [this message]
2026-07-16 13:20 ` [PATCH 07/11] sched_ext: Handle blocked donor migration with proxy execution Andrea Righi
2026-07-16 15:22   ` sashiko-bot
2026-07-16 13:20 ` [PATCH 08/11] sched_ext: Delegate proxy donor admission to BPF schedulers Andrea Righi
2026-07-18  6:16   ` John Stultz
2026-07-18  6:50     ` John Stultz
2026-07-18 14:23       ` Andrea Righi
2026-07-20 16:01         ` Andrea Righi
2026-07-21  0:37           ` John Stultz
2026-07-21  4:54             ` Andrea Righi
2026-07-21  5:15               ` John Stultz
2026-07-16 13:20 ` [PATCH 09/11] sched_ext: Add selftest for blocked donor admission Andrea Righi
2026-07-16 13:20 ` [PATCH 10/11] sched_ext: scx_qmap: Add proxy execution support Andrea Righi
2026-07-16 15:54   ` sashiko-bot
2026-07-18  2:28   ` John Stultz
2026-07-18  5:47     ` Andrea Righi
2026-07-18  6:04       ` John Stultz
2026-07-18  8:24         ` Andrea Righi
2026-07-21  3:39           ` John Stultz
2026-07-16 13:20 ` [PATCH 11/11] sched: Allow enabling proxy exec with sched_ext Andrea Righi
  -- strict thread matches above, loose matches on Subject: below --
2026-07-15 20:54 [PATCHSET v6 sched_ext/for-7.3] sched: Make proxy execution compatible " Andrea Righi
2026-07-15 20:54 ` [PATCH 06/11] sched_ext: Split curr|donor references properly Andrea Righi
2026-07-15 21:15   ` sashiko-bot

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=20260716150252.68BAD1F000E9@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