From: Peng Huang <penghuang@google.com>
To: Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
Andrea Righi <arighi@nvidia.com>,
Changwoo Min <changwoo@igalia.com>
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>,
linux-kernel@vger.kernel.org, sched-ext@lists.linux.dev,
stable@vger.kernel.org, Peng Huang <penghuang@google.com>
Subject: [PATCH v2 1/2] sched/fair: Clear residual sums on zero task-group avg propagation
Date: Mon, 23 Nov 2026 12:13:50 -0800 [thread overview]
Message-ID: <9b14aecb0ad560a3ce5f7925aaaee6e4f4a1a760.1795462673.git.penghuang@google.com> (raw)
In-Reply-To: <cover.1795462673.git.penghuang@google.com>
In update_load_avg(), __update_load_avg_se() ages the group entity @se
before propagate_entity_load_avg() runs. If @se's _avg has already
decayed to 0 while its _sum still holds a sub-divider residual, and the
child gcfs_rq's _avg also reaches 0 (e.g. when its last task detaches),
update_tg_cfs_{util,runnable,load}() see delta_avg == 0 and return early
without subtracting @se's remaining _sum from the parent cfs_rq.
Keep scaling non-zero averages by the parent cfs_rq's divider to
preserve period_contrib alignment, while letting zero-avg propagations
proceed whenever @se still holds a non-zero _sum so the residual is
cleared from both @se and its parent cfs_rq.
Fixes: 7ceb77103001 ("sched/pelt: Continue to relax the sync of util_sum with util_avg")
Suggested-by: Vincent Guittot <vincent.guittot@linaro.org>
Cc: stable@vger.kernel.org
Signed-off-by: Peng Huang <penghuang@google.com>
---
kernel/sched/fair.c | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0c8af1cac2d5..f6c3bbb19557 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5516,9 +5516,15 @@ update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq
long delta_sum, delta_avg = gcfs_rq->avg.util_avg - se->avg.util_avg;
u32 new_sum, divider;
- /* Nothing to update */
- if (!delta_avg)
- return;
+ if (delta_avg == 0) {
+ /* Keep util_sum as-is for unchanged non-zero avg */
+ if (gcfs_rq->avg.util_avg != 0)
+ return;
+
+ /* Nothing to clear once se->avg.util_sum is also 0 */
+ if (se->avg.util_sum == 0)
+ return;
+ }
/*
* cfs_rq->avg.period_contrib can be used for both cfs_rq and se.
@@ -5543,9 +5549,15 @@ update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cf
u64 new_sum;
u32 divider;
- /* Nothing to update */
- if (!delta_avg)
- return;
+ if (delta_avg == 0) {
+ /* Keep runnable_sum as-is for unchanged non-zero avg */
+ if (gcfs_rq->avg.runnable_avg != 0)
+ return;
+
+ /* Nothing to clear once se->avg.runnable_sum is 0 */
+ if (se->avg.runnable_sum == 0)
+ return;
+ }
/*
* cfs_rq->avg.period_contrib can be used for both cfs_rq and se.
@@ -5617,8 +5629,15 @@ update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq
load_avg = div_u64(load_sum, divider);
delta_avg = load_avg - se->avg.load_avg;
- if (!delta_avg)
- return;
+ if (delta_avg == 0) {
+ /* Keep load_sum as-is while child load is non-zero */
+ if (load_sum != 0)
+ return;
+
+ /* Nothing to clear once se->avg.load_sum is also 0 */
+ if (se->avg.load_sum == 0)
+ return;
+ }
delta_sum = load_sum - (s64)se_weight(se) * se->avg.load_sum;
--
2.56.1.831.g720f3f5937-goog
next prev parent reply other threads:[~2026-11-23 20:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 1:57 [PATCH] sched/pelt: Skip dormant cfs util_sum under scx_switched_all Peng Huang
2026-11-23 10:34 ` Vincent Guittot
2026-11-23 16:09 ` Peng Huang
2026-11-23 17:07 ` Vincent Guittot
2026-11-23 20:14 ` Peng Huang
2026-11-23 20:13 ` [PATCH v2 0/2] sched_ext, sched/fair: Drain blocked fair load on scx_switched_all Peng Huang
2026-11-23 20:13 ` Peng Huang [this message]
2026-11-23 20:13 ` [PATCH v2 2/2] sched_ext, sched/fair: Drain blocked " Peng Huang
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=9b14aecb0ad560a3ce5f7925aaaee6e4f4a1a760.1795462673.git.penghuang@google.com \
--to=penghuang@google.com \
--cc=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=dietmar.eggemann@arm.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=stable@vger.kernel.org \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--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®