@@ -259,10 +259,15 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy,
* dvfs_update_delay of the cpufreq governor or min(curr.se.slice, TICK_US),
* whichever is higher.
*
+ * Also take into accounting how long tasks have been waiting in runnable but
+ * !running state. If it is high, it means we need higher DVFS headroom to
+ * reduce it.
+ *
* XXX: Should we provide headroom when the util is decaying?
*/
static inline unsigned long sugov_apply_dvfs_headroom(unsigned long util, int cpu)
{
+ unsigned long update_headroom, waiting_headroom;
struct rq *rq = cpu_rq(cpu);
u64 delay;
@@ -276,7 +281,10 @@ static inline unsigned long sugov_apply_dvfs_headroom(unsigned long util, int c
delay = TICK_USEC;
delay = max(delay, per_cpu(dvfs_update_delay, cpu));
- return approximate_util_avg(util, delay);
+ update_headroom = approximate_util_avg(util, delay);
+ waiting_headroom = util + READ_ONCE(rq->cfs.avg.waiting_avg);
+
+ return max(update_headroom, waiting_headroom);
}
unsigned long sugov_effective_cpu_perf(int cpu, unsigned long actual,
We now have three sources of delays. 1. How often we send cpufreq_updates 2. How often we update util_avg 3. How long tasks wait in RUNNABLE to become RUNNING The headroom should cater for all this type of delays to ensure the system is running at adequate performance point. We want to pick the maximum headroom required by any of these sources of delays. TODO: the signal should use task clock not pelt as this should be real time based and we don't care about invariance. Signed-off-by: Qais Yousef <qyousef@layalina.io> --- kernel/sched/cpufreq_schedutil.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)