Re: [PATCH] sched/pelt: avoid underestimate of task utilization

From: Hongyan Xia
Date: Fri Nov 24 2023 - 05:44:10 EST


On 22/11/2023 14:01, Vincent Guittot wrote:
[...]

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 07f555857698..eeb505d28905 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4774,6 +4774,11 @@ static inline unsigned long task_util(struct task_struct *p)
return READ_ONCE(p->se.avg.util_avg);
}
+static inline unsigned long task_runnable(struct task_struct *p)
+{
+ return READ_ONCE(p->se.avg.runnable_avg);
+}
+
static inline unsigned long _task_util_est(struct task_struct *p)
{
struct util_est ue = READ_ONCE(p->se.avg.util_est);
@@ -4892,6 +4897,14 @@ static inline void util_est_update(struct cfs_rq *cfs_rq,
if (task_util(p) > arch_scale_cpu_capacity(cpu_of(rq_of(cfs_rq))))
return;
+ /*
+ * To avoid underestimate of task utilization, skip updates of ewma if
+ * we cannot grant that thread got all CPU time it wanted.
+ */
+ if ((ue.enqueued + UTIL_EST_MARGIN) < task_runnable(p))
+ goto done;
+
+

Actually, does this also skip util_est increases as well, assuming no FASTUP? When a task is ramping up, another task could join and then blocks this task from ramping up its util_est.

Or do we think this is intended behavior for !FASTUP?

/*
* Update Task's estimated utilization
*