Skip to content

Commit 813ff24

Browse files
vingu-linarogregkh
authored andcommitted
sched/pelt: Ensure that *_sum is always synced with *_avg
[ Upstream commit fcf6631 ] Rounding in PELT calculation happening when entities are attached/detached of a cfs_rq can result into situations where util/runnable_avg is not null but util/runnable_sum is. This is normally not possible so we need to ensure that util/runnable_sum stays synced with util/runnable_avg. detach_entity_load_avg() is the last place where we don't sync util/runnable_sum with util/runnbale_avg when moving some sched_entities Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/20210601085832.12626-1-vincent.guittot@linaro.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f6d28f0 commit 813ff24

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎kernel/sched/fair.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,11 +3767,17 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s
37673767
*/
37683768
static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se)
37693769
{
3770+
/*
3771+
* cfs_rq->avg.period_contrib can be used for both cfs_rq and se.
3772+
* See ___update_load_avg() for details.
3773+
*/
3774+
u32 divider = get_pelt_divider(&cfs_rq->avg);
3775+
37703776
dequeue_load_avg(cfs_rq, se);
37713777
sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg);
3772-
sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum);
3778+
cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider;
37733779
sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg);
3774-
sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum);
3780+
cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider;
37753781

37763782
add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum);
37773783

0 commit comments

Comments
 (0)