mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	John Stultz <jstultz@google.com>,
	Andrea Righi <arighi@nvidia.com>,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org,
	Tejun Heo <tj@kernel.org>
Subject: [PATCH sched/urgent] sched/core: Don't lower rq->next_class in proxy_reset_donor()
Date: Mon,  2 Nov 2026 09:29:07 -1000	[thread overview]
Message-ID: <20261102192907.2177529-1-tj@kernel.org> (raw)

A pick that drops the rq lock, sched_balance_newidle() or
do_pick_task_scx(), first lowers rq->next_class to its own class if it's
above. After relocking, it restarts if rq_modified_above() shows a higher
class wakeup. proxy_reset_donor() sets next_class to rq->curr's class
unconditionally and can lower it in that window. With a sched_ext task as
rq->curr:

1. fair's queue is empty and sched_balance_newidle() drops the rq lock with
   next_class at ext from the last pick.
2. An RT wakeup raises next_class to rt and calls resched_curr().
3. rq->donor, which proxy exec migrated to this CPU, wakes up.
   proxy_needs_return() calls proxy_reset_donor(), which sets next_class
   back to ext.
4. rq_modified_above() sees nothing above fair, sched_ext returns a task and
   __schedule() clears need_resched. The RT task runs only at the CPU's next
   schedule.

This needs a sched_ext donor. With a fair donor, fair's queue isn't empty
and newidle doesn't run, and RT and DL donors are picked before fair. Proxy
exec with sched_ext became possible with c6fe97c34a1a ("sched: Allow
enabling proxy exec with sched_ext").

Only raise next_class in proxy_reset_donor(). next_class above rq->curr's
class is what wakeup_preempt() leaves after any higher class wakeup, and the
->wakeup_preempt() methods ignore a donor of another class since
fa02b2868420 ("sched/core: Fix inter-class wakeup_preempt()"). The
resched_curr() in proxy_reset_donor() makes the next pick set next_class.
The raise stays so that rq_modified_above() still catches a reset to a curr
of a higher class.

Fixes: c6fe97c34a1a ("sched: Allow enabling proxy exec with sched_ext")
Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/sched/core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 04b62c16fa8c..f850f4ae19ea 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3809,7 +3809,12 @@ static inline void proxy_reset_donor(struct rq *rq)
 	WARN_ON_ONCE(rq->donor == rq->curr);
 
 	put_prev_set_next_task(rq, rq->donor, rq->curr);
-	rq->next_class = rq->curr->sched_class;
+	/*
+	 * A pick that dropped the rq lock checks next_class after relocking to
+	 * catch a higher class wakeup, see rq_modified_above(). Don't lower it.
+	 */
+	if (sched_class_above(rq->curr->sched_class, rq->next_class))
+		rq->next_class = rq->curr->sched_class;
 	rq_set_donor(rq, rq->curr);
 	zap_balance_callbacks(rq);
 	resched_curr(rq);
-- 
2.56.0


                 reply	other threads:[~2026-11-02 19:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261102192907.2177529-1-tj@kernel.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jstultz@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /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

all inboxes | Powered by JetHome®