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 sched_ext/for-7.3-fixes] sched_ext: Don't leave balance callbacks queued across a pick retry
Date: Sat, 10 Oct 2026 10:03:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-166417@kernel.org> (raw)
In-Reply-To: <20261010095208.276806-1-arighi@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] sched/ext: Balance callback queued on NULL pick risks lockdep warning during newidle_balance
--

commit 82685b13d2a91f21d4676e7837dbf23573a2e3ac
Author: Andrea Righi <arighi@nvidia.com>

    sched_ext: Don't leave balance callbacks queued across a pick retry

This commit modifies the dispatch path in sched_ext to only queue balance
callbacks when the pick is final. If the core needs to retry or continue the
pick, which may release the runqueue lock, it instead punts the deferred work
to irq_work.

> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index 3f79156467799..54fa382ad8d78 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c

[ ... ]

> @@ -3433,6 +3450,17 @@ do_pick_task_scx(struct rq *rq, struct rq_flags *rf, bool force_scx)
>  	return p;
>  }
>  
> +static struct task_struct *
> +do_pick_task_scx(struct rq *rq, struct rq_flags *rf, bool force_scx)
> +{
> +	struct task_struct *p = __do_pick_task_scx(rq, rf, force_scx);
> +
> +	/* after a NULL pick from the dl_server the lower classes still pick */
> +	pick_queue_balance_callbacks(rq, p != RETRY_TASK && (p || !force_scx));
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Severity: High]
Does this logic incorrectly identify a NULL pick as final when force_scx is
false, leading to premature queueing of balance callbacks?

When a normal sched_ext pick (where force_scx == false) fails to find a task,
it returns NULL. The boolean logic evaluates to true because p != RETRY_TASK
is true (since p is NULL) and !force_scx is true. This marks the pick as final
and queues balance callbacks to rq->balance_callback.

However, a NULL pick from sched_ext is not final for the CPU, as the core
scheduler loop in __pick_next_task() will fall through to lower-priority
scheduling classes, such as fair_sched_class.

If fair also has no runnable tasks, it triggers newidle_balance(), which
unconditionally drops the runqueue lock via rq_unpin_lock() and
raw_spin_rq_unlock().

If another CPU acquires the lock during this window, rq_pin_lock() will
trigger a SCHED_WARN_ON because a balance callback is present on the runqueue
while the lock was unpinned. This defeats the patch's purpose and triggers the
exact lockdep warning it was intended to fix.

> +
> +	return p;
> +}
> +
>  static struct task_struct *pick_task_scx(struct rq *rq, struct rq_flags *rf)
>  {
>  	return do_pick_task_scx(rq, rf, false);

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

  reply	other threads:[~2026-10-10 10:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-10  9:52 [PATCH sched_ext/for-7.3-fixes] sched_ext: Don't leave balance callbacks queued across a pick retry Andrea Righi
2026-10-10 10:03 ` sashiko-bot [this message]
2026-10-10 12:34   ` 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=sashiko-outbox-166417@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.