From: Andrea Righi <arighi@nvidia.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
sched-ext@lists.linux.dev, Tejun Heo <tj@kernel.org>,
David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Jonathan Corbet <corbet@lwn.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>,
Zicheng Qu <quzicheng@huawei.com>
Subject: Re: [RANT][PATCH] sched_ext: Fix stale fair load weight after renice under SCX
Date: Fri, 4 Dec 2026 16:40:23 +0100 [thread overview]
Message-ID: <axLe54vTUeRzDJdk@gpd4> (raw)
In-Reply-To: <20261204093507.424049cf@gandalf.local.home>
Hi Steven,
On Fri, Dec 04, 2026 at 09:35:07AM -0500, Steven Rostedt wrote:
> From: Steven Rostedt (LLM) <rostedt@goodmis.org>
>
> While working on my scheduler governors using Claude, it discovered a bug
> with the sched_ext reweight_task_scx() function. It wrote up the change
> log and created a patch. The change log is below which is mostly from
> Claude, but I did tweak it a little.
>
> set_load_weight() hands a changed weight to the class's ->reweight_task
> and only writes p->se.load itself when the class has no such hook:
>
> if (update_load && p->sched_class->reweight_task)
> p->sched_class->reweight_task(task_rq(p), p, &lw);
> else
> p->se.load = lw;
>
> reweight_task_fair() updates se.load as part of reweighting, but
> reweight_task_scx() only updates p->scx.weight. So a task whose nice
> value changes while it is in the ext class keeps the fair load weight it
> had before, and nothing refreshes it when the task goes back to fair:
> neither switched_from_scx() nor scx_disable_task() does, and fair never
> recomputes a task's weight when it switches in. Forks copy the stale
> se.load too.
We already discussed this with Zicheng and Peter [1]. The approach we
settled on was to rebuild the load weight in switching_to_fair(), so
fair prepares its own state before enqueue, rather than having sched_ext
maintain fair's inactive state.
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -5019,6 +5019,15 @@ static void reweight_task_scx(struct rq *rq, struct task_struct *p,
>
> lockdep_assert_rq_held(task_rq(p));
>
> + /*
> + * set_load_weight() leaves se.load to the class when it has
> + * ->reweight_task. Keep it current: it is the weight the task takes
> + * back to the fair class. This must come before the early returns
> + * below, as a task switching from SCX to fair through
> + * sched_setscheduler() is reweighted here after scx_disable_task().
> + */
> + p->se.load = *lw;
> +
There is also the associated PELT state to consider here,
se->avg.load_avg depends on the load weight, so updating se.load alone
can leave them inconsistent when the task returns to fair.
Zicheng's v4 series [2] addressed both pieces: rebuilding the weight
in switching_to_fair() and recalculating load_avg before attaching the
entity back to fair.
Peter, Zicheng, do you remember why that series did not land upstream?
Was there any open issue to address, or did the series simply fall
through the cracks?
Could we revisit that approach before adding the fair-state update
to reweight_task_scx()?
[1] https://lore.kernel.org/r/20260527112624.GT3126523@noisy.programming.kicks-ass.net
[2] https://lore.kernel.org/r/20260624091648.271891-1-quzicheng@huawei.com
[3] https://lore.kernel.org/r/ajvGJ4Uui745fbBA@gpd4
Thanks,
-Andrea
next prev parent reply other threads:[~2026-12-04 15:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 14:35 [RANT][PATCH] sched_ext: Fix stale fair load weight after renice under SCX Steven Rostedt
2026-12-04 15:19 ` Tejun Heo
2026-12-04 15:40 ` Andrea Righi [this message]
2026-12-04 15:44 ` Tejun Heo
2026-12-04 15:59 ` Steven Rostedt
2026-12-04 16:33 ` Andrea Righi
2026-12-04 16:53 ` Steven Rostedt
2026-12-04 17:04 ` Andrea Righi
2026-12-04 17:16 ` Steven Rostedt
2026-12-04 17:27 ` Tejun Heo
2026-12-04 17:38 ` Sasha Levin
2026-12-04 17:29 ` Andrea Righi
2026-12-04 17:59 ` Steven Rostedt
2026-12-04 17:36 ` Sasha Levin
2026-12-04 16:19 ` Peter Zijlstra
2026-12-04 18:06 ` Linus Torvalds
2026-12-04 18:47 ` Steven Rostedt
2026-12-04 18:57 ` Linus Torvalds
2026-12-04 19:29 ` Steven Rostedt
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=axLe54vTUeRzDJdk@gpd4 \
--to=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=quzicheng@huawei.com \
--cc=rostedt@goodmis.org \
--cc=sashal@kernel.org \
--cc=sched-ext@lists.linux.dev \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=void@manifault.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