From: sashiko-bot@kernel.org
To: "Steven Rostedt" <rostedt@goodmis.org>, sched-ext@lists.linux.dev
Subject: Re: [RANT][PATCH] sched_ext: Fix stale fair load weight after renice under SCX
Date: Fri, 04 Dec 2026 15:00:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-250043@kernel.org> (raw)
In-Reply-To: <20261204093507.424049cf@gandalf.local.home>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched_ext: reweight_task_scx() updates se.load without
rescaling load_avg
--
commit 1b86025ef32391b326ae8f39902ded0ecc0ca419
Author: Steven Rostedt (LLM) <rostedt@goodmis.org>
sched_ext: Fix stale fair load weight after renice under SCX
This commit stores the new weight in p->se.load at the start of
reweight_task_scx() so that tasks whose nice value changes while in
ext_sched_class carry the updated fair load weight back to fair_sched_class.
> diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
> index a9e36b5bb0386..5aca62ef08a75 100644
> --- a/kernel/sched/ext/ext.c
> +++ b/kernel/sched/ext/ext.c
> @@ -5018,6 +5018,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;
[Severity: Medium]
Does updating p->se.load without rescaling p->se.avg.load_avg violate PELT
load invariants when the task returns to fair_sched_class?
If a task lowers its weight in ext_sched_class (for example, switching from
SCHED_EXT at nice 0 to SCHED_IDLE via sched_setattr()) and returns to
fair_sched_class within the same 1024us PELT period, __update_load_avg_se()
skips ___update_load_avg().
se->avg.load_avg then remains scaled to the old, higher weight when
switched_to_fair() -> attach_entity_cfs_rq() calls attach_entity_load_avg():
kernel/sched/fair.c:attach_entity_load_avg() {
...
se->avg.load_sum = se->avg.load_avg * divider;
if (se_weight(se) < se->avg.load_sum)
se->avg.load_sum = div_u64(se->avg.load_sum, se_weight(se));
else
se->avg.load_sum = 1;
enqueue_load_avg(cfs_rq, se);
...
}
Dividing by the new smaller se_weight(se) without clamping to LOAD_AVG_MAX
inflates se->avg.load_sum (up to ~341x LOAD_AVG_MAX for nice 0 to SCHED_IDLE)
and enqueues the inflated load onto cfs_rq->avg, distorting CFS load
balancing and cgroup share calculations.
Should p->se.avg.load_avg be rescaled alongside p->se.load (as
reweight_entity() does) when updating the weight here?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204093507.424049cf@gandalf.local.home?part=1
next prev parent reply other threads:[~2026-12-04 15:00 UTC|newest]
Thread overview: 21+ 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:00 ` sashiko-bot [this message]
2026-12-04 15:19 ` Tejun Heo
2026-12-04 15:40 ` Andrea Righi
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
2026-12-05 13: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=sashiko-outbox-250043@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=rostedt@goodmis.org \
--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.