* [PATCH] sched/fair: Fix removal of load and runnable sums on 32-bit
@ 2026-12-01 16:43 Tim Douglas
0 siblings, 0 replies; only message in thread
From: Tim Douglas @ 2026-12-01 16:43 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Vincent Guittot, Juri Lelli
Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, K Prateek Nayak, linux-kernel, Tim Douglas,
stable
Since commit 089d84203ad4 ("sched/fair: Fold the sched_avg update"),
update_cfs_rq_load_avg() drains cfs_rq->removed with -r*divider as the
sum delta, where r is an unsigned long. On 32-bit, the product is a
32-bit unsigned value, which add_positive() zero-extends to the s64
delta for load_sum and runnable_sum. For 0 < r*divider < 2^32, the
resulting delta is 2^32 too large. (The u32 util_sum update is
unaffected.)
For runnable_sum, that excess corresponds to about 90000 units of
runnable_avg before decay, which saturates cpu_util_cfs_boost() and
causes schedutil to select the highest CPU frequency on a mostly idle
system. Seen on an Allwinner R16 (Cortex-A7) with runnable_avg up to
342000 and at most three runnable tasks. With the fix, the highest
runnable_avg in 73000 samples under the same workload was 1828, and
schedutil scaled with load as expected.
Make r an s64 so that the delta is computed in 64 bits.
Fixes: 089d84203ad4 ("sched/fair: Fold the sched_avg update")
Cc: stable@vger.kernel.org
Signed-off-by: Tim Douglas <me@timdoug.com>
---
kernel/sched/fair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8a55571b9..74d4f9ced 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5814,7 +5814,7 @@ update_cfs_rq_load_avg(u64 now, struct cfs_rq *cfs_rq)
int decayed = 0;
if (cfs_rq->removed.nr) {
- unsigned long r;
+ s64 r;
u32 divider = get_pelt_divider(&cfs_rq->avg);
raw_spin_lock(&cfs_rq->removed.lock);
--
2.56.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-01 16:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 16:43 [PATCH] sched/fair: Fix removal of load and runnable sums on 32-bit Tim Douglas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox