mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
sched/fair: Fast ramp-up EWMA on utilization increases
The estimated utilization for a task: util_est = max(util_avg, est.enqueue, est.ewma) is defined based on: - util_avg: the PELT defined utilization - est.enqueued: the util_avg at the end of the last activation - est.ewma: a exponential moving average on the est.enqueued samples According to this definition, when a task suddenly change its bandwidth requirements from small to big, the EWMA will need to collect multiple samples before converging up to track the new big utilization. This slow convergence towards bigger utilization values is not aligned to the default scheduler behavior, which is to optimize for performance. Moreover, the est.ewma component fails to compensate for temporarely utilization drops which spans just few est.enqueued samples. To let util_est do a better job in the scenario depicted above, change its definition by making util_est directly follow upward motion and only decay the est.ewma on downward. https://lkml.org/lkml/2019/10/23/1071 Change-Id: I1837e322b02958faeaff65563127e6ab682c93e1 Cc: Ingo Molnar <mingo@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Patrick Bellasi <patrick.bellasi@matbug.com> Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com> Signed-off-by: Yaroslav Furman <yaro330@gmail.com> Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This commit is contained in:
parent
61e59264a4
commit
d34e463b5b
@ -3884,11 +3884,22 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep)
|
||||
if (ue.enqueued & UTIL_AVG_UNCHANGED)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Reset EWMA on utilization increases, the moving average is used only
|
||||
* to smooth utilization decreases.
|
||||
*/
|
||||
ue.enqueued = (task_util(p) | UTIL_AVG_UNCHANGED);
|
||||
if (sched_feat(UTIL_EST_FASTUP)) {
|
||||
if (ue.ewma < ue.enqueued) {
|
||||
ue.ewma = ue.enqueued;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip update of task's estimated utilization when its EWMA is
|
||||
* already ~1% close to its last activation value.
|
||||
*/
|
||||
ue.enqueued = (task_util(p) | UTIL_AVG_UNCHANGED);
|
||||
last_ewma_diff = ue.enqueued - ue.ewma;
|
||||
if (within_margin(last_ewma_diff, (SCHED_CAPACITY_SCALE / 100)))
|
||||
return;
|
||||
@ -3913,6 +3924,7 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep)
|
||||
ue.ewma <<= UTIL_EST_WEIGHT_SHIFT;
|
||||
ue.ewma += last_ewma_diff;
|
||||
ue.ewma >>= UTIL_EST_WEIGHT_SHIFT;
|
||||
done:
|
||||
WRITE_ONCE(p->se.avg.util_est, ue);
|
||||
|
||||
trace_sched_util_est_task(p, &p->se.avg);
|
||||
|
@ -92,6 +92,7 @@
|
||||
* UtilEstimation. Use estimated CPU utilization.
|
||||
*/
|
||||
#define SCHED_FEAT_UTIL_EST 1
|
||||
#define SCHED_FEAT_UTIL_EST_FASTUP 1
|
||||
|
||||
/*
|
||||
* Energy aware scheduling. Use platform energy model to guide scheduling
|
||||
|
Loading…
x
Reference in New Issue
Block a user