sched/pelt: sync util/runnable_sum with PELT window when propagating
Vincent Guittot
maintainerPATCH 1/1 sched/pelt: sync util/runnable_sum with PELT window when propagating
update_tg_cfs_util/runnable() propagate the impact of the attach/detach of an entity down into the cfs_rq hierarchy which must keep the sync with the current pelt window.
Even if we can't sync child rq and its group se, we can sync the group se and parent cfs_rq with current PELT window. In fact, we must keep them sync in order to stay also synced with others se and group se that are already attached to the cfs_rq.
--- kernel/sched/fair.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)
kernel/sched/fair.c +6 -20
@@ -3441,52 +3441,38 @@ static inline void update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) { long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */ if (!delta)return ; -/* -* The relation between sum and avg is: -* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/ -/* Set new sched_entity's utilization */ se->avg.util_avg = gcfs_rq->avg.util_avg; - se->avg.util_sum = se->avg.util_avg *LOAD_AVG_MAX ; + se->avg.util_sum = se->avg.util_avg * divider;/* Update parent cfs_rq utilization */ add_positive (&cfs_rq->avg.util_avg, delta); - cfs_rq->avg.util_sum = cfs_rq->avg.util_avg *LOAD_AVG_MAX ; + cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; }static inline void update_tg_cfs_runnable (struct cfs_rq *cfs_rq,struct sched_entity *se,struct cfs_rq *gcfs_rq) {long delta = gcfs_rq->avg.runnable_avg - se->avg.runnable_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */ if (!delta)return ; -/* -* The relation between sum and avg is: -* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/ -/* Set new sched_entity's runnable */ se->avg.runnable_avg = gcfs_rq->avg.runnable_avg; - se->avg.runnable_sum = se->avg.runnable_avg *LOAD_AVG_MAX ; + se->avg.runnable_sum = se->avg.runnable_avg * divider;/* Update parent cfs_rq runnable */ add_positive (&cfs_rq->avg.runnable_avg, delta); - cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg *LOAD_AVG_MAX ; + cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; } static inline void
Signature · 1 line
2.17.1
Dietmar Eggemann
reviewerQuoted 5 lines · Vincent Guittot
update_tg_cfs_util/runnable() propagate the impact of the attach/detach of an entity down into the
cfs_rqhierarchy which must keep the sync with the current pelt window.Even if we can't sync child rq and its group se, we can sync the group se
So we have
gcfs --> tg --> gse
________________|
|
V
cfs ---> tg (root)
|
V
rqhere. What is 'child rq' for 'group se' here? I guess 'parent cfs_rq' is cfs_rq.
Quoted 25 lines
and parent
cfs_rqwith current PELT window. In fact, we must keep them sync in order to stay also synced with others se and group se that are already attached to thecfs_rq.Signed-off-by Vincent Guittot <[email protected]>--- kernel/sched/fair.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)kernel/sched/fair.c +1
-2@@ -3441,52 +3441,38 @@ static inline void update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) { long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */ if (!delta)return ; -/* -* The relation between sum and avg is:
kernel/sched/fair.c static inline void · line 3452
Quoted 10 lines
kernel/sched/fair.c +1
-7-* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/ -/* Set new sched_entity's utilization */ se->avg.util_avg = gcfs_rq->avg.util_avg; - se->avg.util_sum = se->avg.util_avg *LOAD_AVG_MAX ; + se->avg.util_sum = se->avg.util_avg * divider;
divider uses cfs_rq but we sync se->avg.util_avg with gcfs_rq here.
But since avg.period_contrib of cfs_rq and gcfs_rq are the same this should work.
kernel/sched/fair.c static inline void · line 3456
Quoted 4 lines
kernel/sched/fair.c +1
-1/* Update parent cfs_rq utilization */ add_positive (&cfs_rq->avg.util_avg, delta); - cfs_rq->avg.util_sum = cfs_rq->avg.util_avg *LOAD_AVG_MAX ; + cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider;
Looks like that avg.last_update_time of se (group entity), it's gcfs_rq and cfs_rq is always the same in update_tg_cfs_[util\|runnable].
So that means the PELT windows are aligned for cfs_rqs and group se's?
And if we want to enforce this for cfs_rq and task, we have sync_entity_load_avg().
[...]
Vincent Guittot
maintainerQuoted 12 lines · Dietmar Eggemann
Quoted 5 lines · Vincent Guittot
update_tg_cfs_util/runnable() propagate the impact of the attach/detach of an entity down into the
cfs_rqhierarchy which must keep the sync with the current pelt window.Even if we can't sync child rq and its group se, we can sync the group se
So we have
Quoted 12 lines
gcfs --> tg --> gse
________________|
|
V
cfs ---> tg (root)
|
V
rqchild cfs_rq aka gcfs_rq
|
gse: group entity that represents child cfs_rq in parent cfs_rq
|
v
parent cfs_rq aka cfs_rq
Quoted 27 lines
here. What is 'child rq' for 'group se' here? I guess 'parent
cfs_rq' iscfs_rq.Quoted 23 lines
and parent
cfs_rqwith current PELT window. In fact, we must keep them sync in order to stay also synced with others se and group se that are already attached to thecfs_rq.Signed-off-by Vincent Guittot <[email protected]>--- kernel/sched/fair.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)kernel/sched/fair.c +1
-0@@ -3441,52 +3441,38 @@ static inline void update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) { long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */ if (!delta)return ;
Quoted 14 lines
kernel/sched/fair.c static inline void · line 3452
Quoted 12 lines
kernel/sched/fair.c +1
-9-/* -* The relation between sum and avg is: -* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/ -/* Set new sched_entity's utilization */ se->avg.util_avg = gcfs_rq->avg.util_avg; - se->avg.util_sum = se->avg.util_avg *LOAD_AVG_MAX ; + se->avg.util_sum = se->avg.util_avg * divider;divider uses
cfs_rqbut we syncse->avg.util_avgwithgcfs_rqhere.
we sync the util_avg of gse with the new util_avg of gcfs_rq but gse is attached to cfs_rq and as a result we have to use cfs_rq's period_contrib
Quoted 9 lines
But since avg.period_contrib of
cfs_rqandgcfs_rqare the same this should work.kernel/sched/fair.c static inline void · line 3456
Quoted 4 lines
kernel/sched/fair.c +1
-1/* Update parent cfs_rq utilization */ add_positive (&cfs_rq->avg.util_avg, delta); - cfs_rq->avg.util_sum = cfs_rq->avg.util_avg *LOAD_AVG_MAX ; + cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider;
Quoted 4 lines
Looks like that avg.last_update_time of se (group entity), it's
gcfs_rqandcfs_rqis always the same in update_tg_cfs_[util\|runnable].So that means the PELT windows are aligned for
cfs_rqsand group se's?
We want to align util_avg with util_sum and period_contrib otherwise we might have some unalignment. It's quite similarly to what is done in attach_entity_load_avg()
Quoted 3 lines
And if we want to enforce this for
cfs_rqand task, we havesync_entity_load_avg().
It's not a matter of syncing the last_update_time
Quoted 2 lines
[...]
Dietmar Eggemann
reviewerQuoted 3 lines · Vincent Guittot
Quoted 2 lines · Dietmar Eggemann
On 22/04/2020 17:14, Vincent Guittot wrote:
[..]
Quoted 13 lines
Quoted 12 lines
gcfs --> tg --> gse ________________| | V cfs ---> tg (root) | V rq
Quoted 6 lines
child
cfs_rqakagcfs_rq
|
gse: group entity that represents childcfs_rqin parentcfs_rq
|
v
parentcfs_rqakacfs_rq
OK, I see. Maybe it's clearer to refer to child cfs_rq as gcfs_rq in this context.
[...]
Quoted 10 lines
Quoted 6 lines
kernel/sched/fair.c static inline void · line 3452
Quoted 4 lines
/* Set new sched_entity's utilization */ se->avg.util_avg = gcfs_rq->avg.util_avg;kernel/sched/fair.c +1
-1- se->avg.util_sum = se->avg.util_avg *LOAD_AVG_MAX ; + se->avg.util_sum = se->avg.util_avg * divider;divider uses
cfs_rqbut we syncse->avg.util_avgwithgcfs_rqhere.we sync the
util_avgof gse with the newutil_avgofgcfs_rqbut gse is attached tocfs_rqand as a result we have to use cfs_rq'speriod_contrib
I agree.
But the decay windows (avg.last_update_time, avg.period_contrib) of cfs_rq and gcfs_rq are not always aligned, I guess?
I see they are not after the online_fair_sched_group() -> attach_entity_cfs_rq() but later the are in sync as well.
I ran a couple of different rt-app taskgroup tests and try to
BUG_ON(se->avg.period_contrib != gcfs_rq->avg.period_contrib); BUG_ON(se->avg.last_update_time != gcfs_rq->avg.last_update_time)
in update_tg_cfs_util() but they didn't trigger so far.
Both, cfs_rq and gcfs_rq are in sync in update_tg_cfs_util() before and during a task runs in gcfs_rq.
Are there cases where this wouldn't necessary happen in update_tg_cfs_util(), maybe a more complicated testcase?
Quoted 8 lines
Quoted 8 lines
But since avg.period_contrib of
cfs_rqandgcfs_rqare the same this should work.Quoted 4 lines
/* Update parent cfs_rq utilization */ add_positive(&cfs_rq->avg.util_avg, delta);kernel/sched/fair.c +1
-1- cfs_rq->avg.util_sum = cfs_rq->avg.util_avg *LOAD_AVG_MAX ; + cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider;
Quoted 8 lines
Quoted 4 lines
Looks like that avg.last_update_time of se (group entity), it's
gcfs_rqandcfs_rqis always the same in update_tg_cfs_[util\|runnable].So that means the PELT windows are aligned for
cfs_rqsand group se's?We want to align
util_avgwithutil_sumandperiod_contribotherwise we might have some unalignment. It's quite similarly to what is done inattach_entity_load_avg()
I agree.
Quoted 4 lines
Quoted 2 lines
And if we want to enforce this for
cfs_rqand task, we havesync_entity_load_avg().It's not a matter of syncing the
last_update_time
I agree, this is not what you want to achieve here.
But syncing 'last_update_time' and 'period_contrib' is what I understand as aligning the decay window (like in attach_entity_load_avg()).
Vincent Guittot
maintainerQuoted 44 lines · Dietmar Eggemann
Quoted 3 lines · Vincent Guittot
Quoted 2 lines · Dietmar Eggemann
On 22/04/2020 17:14, Vincent Guittot wrote:
[..]
Quoted 13 lines
Quoted 12 lines
gcfs --> tg --> gse ________________| | V cfs ---> tg (root) | V rqQuoted 6 lines
child
cfs_rqakagcfs_rq
|
gse: group entity that represents childcfs_rqin parentcfs_rq
|
v
parentcfs_rqakacfs_rqOK, I see. Maybe it's clearer to refer to child
cfs_rqasgcfs_rqin this context.[...]
Quoted 10 lines
Quoted 6 lines
kernel/sched/fair.c static inline void · line 3452
Quoted 4 lines
/* Set new sched_entity's utilization */ se->avg.util_avg = gcfs_rq->avg.util_avg;kernel/sched/fair.c +1
-1- se->avg.util_sum = se->avg.util_avg *LOAD_AVG_MAX ; + se->avg.util_sum = se->avg.util_avg * divider;divider uses
cfs_rqbut we syncse->avg.util_avgwithgcfs_rqhere.we sync the
util_avgof gse with the newutil_avgofgcfs_rqbut gse is attached tocfs_rqand as a result we have to use cfs_rq'speriod_contrib
Quoted 7 lines
I agree.
But the decay windows (avg.last_update_time, avg.period_contrib) of
cfs_rqandgcfs_rqare not always aligned, I guess?I see they are not after the
online_fair_sched_group()->attach_entity_cfs_rq()but later the are in sync as well.
cfs_rq and gcfs_rq use 2 different clocks:
- cfs_rq_clock_pelt(cfs_rq)
- cfs_rq_clock_pelt(gcfs_rq)
And they can be different in some cases like cfs bandwidth
Quoted 41 lines
I ran a couple of different rt-app taskgroup tests and try to
BUG_ON(se->avg.period_contrib != gcfs_rq->avg.period_contrib);BUG_ON(se->avg.last_update_time != gcfs_rq->avg.last_update_time)in
update_tg_cfs_util()but they didn't trigger so far.Both,
cfs_rqandgcfs_rqare in sync inupdate_tg_cfs_util()before and during a task runs ingcfs_rq.Are there cases where this wouldn't necessary happen in
update_tg_cfs_util(), maybe a more complicated testcase?Quoted 8 lines
Quoted 8 lines
But since avg.period_contrib of
cfs_rqandgcfs_rqare the same this should work.Quoted 4 lines
/* Update parent cfs_rq utilization */ add_positive(&cfs_rq->avg.util_avg, delta);kernel/sched/fair.c +1
-1- cfs_rq->avg.util_sum = cfs_rq->avg.util_avg *LOAD_AVG_MAX ; + cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider;Quoted 8 lines
Quoted 4 lines
Looks like that avg.last_update_time of se (group entity), it's
gcfs_rqandcfs_rqis always the same in update_tg_cfs_[util\|runnable].So that means the PELT windows are aligned for
cfs_rqsand group se's?We want to align
util_avgwithutil_sumandperiod_contribotherwise we might have some unalignment. It's quite similarly to what is done inattach_entity_load_avg()I agree.
Quoted 4 lines
Quoted 2 lines
And if we want to enforce this for
cfs_rqand task, we havesync_entity_load_avg().It's not a matter of syncing the
last_update_timeI agree, this is not what you want to achieve here.
But syncing 'last_update_time' and 'period_contrib' is what I understand as aligning the decay window (like inattach_entity_load_avg()).
Peter Zijlstra
maintainerQuoted 25 lines · Vincent Guittot
update_tg_cfs_util/runnable() propagate the impact of the attach/detach of an entity down into the
cfs_rqhierarchy which must keep the sync with the current pelt window.Even if we can't sync child rq and its group se, we can sync the group se and parent
cfs_rqwith current PELT window. In fact, we must keep them sync in order to stay also synced with others se and group se that are already attached to thecfs_rq.Signed-off-by Vincent Guittot <[email protected]>--- kernel/sched/fair.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)kernel/sched/fair.c +1
-0@@ -3441,52 +3441,38 @@ static inline void update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) { long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */
kernel/sched/fair.c static inline void · line 3455
Quoted 10 lines
kernel/sched/fair.c +0
-7if (!delta)return ; -/* -* The relation between sum and avg is: -* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/
Instead of deleting this, could we perhaps extend it?
Vincent Guittot
maintainerQuoted 30 lines · Peter Zijlstra
Quoted 28 lines · Vincent Guittot
update_tg_cfs_util/runnable() propagate the impact of the attach/detach of an entity down into the
cfs_rqhierarchy which must keep the sync with the current pelt window.Even if we can't sync child rq and its group se, we can sync the group se and parent
cfs_rqwith current PELT window. In fact, we must keep them sync in order to stay also synced with others se and group se that are already attached to thecfs_rq.Signed-off-by Vincent Guittot <[email protected]>--- kernel/sched/fair.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)kernel/sched/fair.c +1
-0@@ -3441,52 +3441,38 @@ static inline void update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) { long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */ if (!delta)return ;
Quoted 9 lines
kernel/sched/fair.c static inline void · line 3455
Quoted 7 lines
kernel/sched/fair.c +0
-7-/* -* The relation between sum and avg is: -* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/ Instead of deleting this, could we perhaps extend it?
In fact, this is not the only place in fair.c that uses this rule to align _avg and _sum but others don't have any special comment.
I can add a more detailed description of this relation for ___update_load_avg() in pelt.c and make a ref to this in all places in fair.c that use this rule which are :
- update_tg_cfs_util
- update_tg_cfs_runnable
- update_cfs_rq_load_avg
- attach_entity_load_avg
- reweight_entity
Dietmar Eggemann
reviewerQuoted 44 lines · Vincent Guittot
Quoted 30 lines · Peter Zijlstra
Quoted 28 lines · Vincent Guittot
update_tg_cfs_util/runnable() propagate the impact of the attach/detach of an entity down into the
cfs_rqhierarchy which must keep the sync with the current pelt window.Even if we can't sync child rq and its group se, we can sync the group se and parent
cfs_rqwith current PELT window. In fact, we must keep them sync in order to stay also synced with others se and group se that are already attached to thecfs_rq.Signed-off-by Vincent Guittot <[email protected]>--- kernel/sched/fair.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)kernel/sched/fair.c +1
-0@@ -3441,52 +3441,38 @@ static inline void update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) { long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */ if (!delta)return ;Quoted 9 lines
kernel/sched/fair.c static inline void · line 3455
Quoted 7 lines
kernel/sched/fair.c +0
-7-/* -* The relation between sum and avg is: -* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/ Instead of deleting this, could we perhaps extend it?
In fact, this is not the only place in
fair.cthat uses this rule to align_avgand_sumbut others don't have any special comment.
Quoted 8 lines
I can add a more detailed description of this relation for
___update_load_avg()inpelt.cand make a ref to this in all places infair.cthat use this rule which are :
-update_tg_cfs_util
-update_tg_cfs_runnable
-update_cfs_rq_load_avg
-attach_entity_load_avg
-reweight_entity
But IMHO the
"* however, the PELT windows are not aligned between grq and gse."
should only apply to update_tg_cfs_util() and update_tg_cfs_runnable(). And attach_entity_load_avg() (for cfs_rq and se).
They seem to be special since we derive divider from a cfs_rq PELT value and use it for a se PELT value.
I assume this fact is specifically worth highlighting with a comment. I mean the fact we can do this because the decay windows are actually aligned.
Vincent Guittot
maintainerQuoted 57 lines · Dietmar Eggemann
Quoted 44 lines · Vincent Guittot
Quoted 30 lines · Peter Zijlstra
Quoted 28 lines · Vincent Guittot
update_tg_cfs_util/runnable() propagate the impact of the attach/detach of an entity down into the
cfs_rqhierarchy which must keep the sync with the current pelt window.Even if we can't sync child rq and its group se, we can sync the group se and parent
cfs_rqwith current PELT window. In fact, we must keep them sync in order to stay also synced with others se and group se that are already attached to thecfs_rq.Signed-off-by Vincent Guittot <[email protected]>--- kernel/sched/fair.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)kernel/sched/fair.c +1
-0@@ -3441,52 +3441,38 @@ static inline void update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) { long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */ if (!delta)return ;Quoted 9 lines
kernel/sched/fair.c static inline void · line 3455
Quoted 7 lines
kernel/sched/fair.c +0
-7-/* -* The relation between sum and avg is: -* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/ Instead of deleting this, could we perhaps extend it?
In fact, this is not the only place in
fair.cthat uses this rule to align_avgand_sumbut others don't have any special comment.Quoted 8 lines
I can add a more detailed description of this relation for
___update_load_avg()inpelt.cand make a ref to this in all places infair.cthat use this rule which are :
-update_tg_cfs_util
-update_tg_cfs_runnable
-update_cfs_rq_load_avg
-attach_entity_load_avg
-reweight_entityBut IMHO the
Quoted 7 lines
"* however, the PELT windows are not aligned between grq and gse."
should only apply to
update_tg_cfs_util()andupdate_tg_cfs_runnable(). Andattach_entity_load_avg()(forcfs_rqand se).They seem to be special since we derive divider from a
cfs_rqPELT value and use it for a se PELT value.
hmmm... There is nothing special here.
When se is attached to cfs_rq, they both have the same divider because they use the same clock.
Quoted 3 lines
I assume this fact is specifically worth highlighting with a comment. I mean the fact we can do this because the decay windows are actually aligned.
Dietmar Eggemann
reviewerQuoted 6 lines · Vincent Guittot
Quoted 5 lines · Dietmar Eggemann
Quoted 3 lines · Vincent Guittot
Quoted 2 lines · Peter Zijlstra
On Wed, Apr 22, 2020 at 05:14:01PM +0200, Vincent Guittot wrote:
[...]
Quoted 43 lines
Quoted 43 lines
Quoted 27 lines
Quoted 14 lines
Quoted 14 lines
kernel/sched/fair.c +1
-0@@ -3441,52 +3441,38 @@ static inline void update_tg_cfs_util(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) { long delta = gcfs_rq->avg.util_avg - se->avg.util_avg; +u32 divider =LOAD_AVG_MAX -1024 + cfs_rq->avg.period_contrib;/* Nothing to update */ if (!delta)return ;Quoted 9 lines
kernel/sched/fair.c static inline void · line 3455
Quoted 7 lines
kernel/sched/fair.c +0
-7-/* -* The relation between sum and avg is: -* -* LOAD_AVG_MAX - 1024 + sa->period_contrib -* -* however, the PELT windows are not aligned between grq and gse. -*/ Instead of deleting this, could we perhaps extend it?
In fact, this is not the only place in
fair.cthat uses this rule to align_avgand_sumbut others don't have any special comment.Quoted 8 lines
I can add a more detailed description of this relation for
___update_load_avg()inpelt.cand make a ref to this in all places infair.cthat use this rule which are :
-update_tg_cfs_util
-update_tg_cfs_runnable
-update_cfs_rq_load_avg
-attach_entity_load_avg
-reweight_entityBut IMHO the
"* however, the PELT windows are not aligned between grq and gse."
should only apply to
update_tg_cfs_util()andupdate_tg_cfs_runnable(). Andattach_entity_load_avg()(forcfs_rqand se).
Quoted 7 lines
Quoted 2 lines
They seem to be special since we derive divider from a
cfs_rqPELT value and use it for a se PELT value.hmmm... There is nothing special here.
When se is attached to
cfs_rq, they both have the same divider because they use the same clock.
That's true.
But exactly this might deserve this comment. Otherwise people might wonder why you can do a
u32 divider = LOAD_AVG_MAX - 1024 + *cfs_rq*->avg.period_contrib;
and use it for instance in:
*se*->avg.util_sum = se->avg.util_avg * divider;
In update_cfs_rq_load_avg() and reweight_entity() we derive 'divider' from the same 'sched_avg' we use it on later.
u32 divider = LOAD_AVG_MAX - 1024 + sa->period_contrib;
sub_positive(&sa->load_sum, r * divider);[...]