Skip to content

Commit 10a35e6

Browse files
vingu-linaroingomolnar
authored andcommitted
sched/pelt: Skip updating util_est when utilization is higher than CPU's capacity
util_est is mainly meant to be a lower-bound for tasks utilization. That's why task_util_est() returns the actual util_avg when it's higher than the estimated utilization. With new invaraince signal and without any special check on samples collection, if a task is limited because of thermal capping for example, we could end up overestimating its utilization and thus perhaps generating an unwanted frequency spike when the capping is relaxed... and (even worst) it will take some more activations for the estimated utilization to converge back to the actual utilization. Since we cannot easily know if there is idle time in a CPU when a task completes an activation with a utilization higher then the CPU capacity, we skip the sampling when utilization is higher than CPU's capacity. Suggested-by: Patrick Bellasi <patrick.bellasi@arm.com> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Morten.Rasmussen@arm.com Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: bsegall@google.com Cc: dietmar.eggemann@arm.com Cc: pjt@google.com Cc: pkondeti@codeaurora.org Cc: quentin.perret@arm.com Cc: rjw@rjwysocki.net Cc: srinivas.pandruvada@linux.intel.com Cc: thara.gopinath@linaro.org Link: https://lkml.kernel.org/r/1548257214-13745-4-git-send-email-vincent.guittot@linaro.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 2312729 commit 10a35e6

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎kernel/sched/fair.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,6 +3638,7 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep)
36383638
{
36393639
long last_ewma_diff;
36403640
struct util_est ue;
3641+
int cpu;
36413642

36423643
if (!sched_feat(UTIL_EST))
36433644
return;
@@ -3671,6 +3672,14 @@ util_est_dequeue(struct cfs_rq *cfs_rq, struct task_struct *p, bool task_sleep)
36713672
if (within_margin(last_ewma_diff, (SCHED_CAPACITY_SCALE / 100)))
36723673
return;
36733674

3675+
/*
3676+
* To avoid overestimation of actual task utilization, skip updates if
3677+
* we cannot grant there is idle time in this CPU.
3678+
*/
3679+
cpu = cpu_of(rq_of(cfs_rq));
3680+
if (task_util(p) > capacity_orig_of(cpu))
3681+
return;
3682+
36743683
/*
36753684
* Update Task's estimated utilization
36763685
*
@@ -5542,11 +5551,6 @@ static unsigned long capacity_of(int cpu)
55425551
return cpu_rq(cpu)->cpu_capacity;
55435552
}
55445553

5545-
static unsigned long capacity_orig_of(int cpu)
5546-
{
5547-
return cpu_rq(cpu)->cpu_capacity_orig;
5548-
}
5549-
55505554
static unsigned long cpu_avg_load_per_task(int cpu)
55515555
{
55525556
struct rq *rq = cpu_rq(cpu);

‎kernel/sched/sched.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,13 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) {}
22302230
# define arch_scale_freq_invariant() false
22312231
#endif
22322232

2233+
#ifdef CONFIG_SMP
2234+
static inline unsigned long capacity_orig_of(int cpu)
2235+
{
2236+
return cpu_rq(cpu)->cpu_capacity_orig;
2237+
}
2238+
#endif
2239+
22332240
#ifdef CONFIG_CPU_FREQ_GOV_SCHEDUTIL
22342241
/**
22352242
* enum schedutil_type - CPU utilization type

0 commit comments

Comments
 (0)