CPU utilization is not only about CFS utilization, it also includes RT/DL utilization. Current code we track utilization with both PELT and WALT signals.
For PELT signal: CFS has its own utilization tracking, and has another signal which uses PELT algorithm to track RT/DL utilization value;
For WALT signal: WALT signal has accumulated all scheduling class utilization into single one signal, so directly use the value return back from cpu_util().
This commit provides the two functions to calculate the CPU summed utilization, the function cpu_util_sum() returns the summed utilization for specified CPU; the function __cpu_util_sum() needs to pass the CFS and RT utilization value and return back summed value, so this function can be used for some estimation case, e.g. we can pass the estimated CFS utilization if place one waken task on the specified CPU.
Signed-off-by: Leo Yan leo.yan@linaro.org --- kernel/sched/sched.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index d01a06f..1928d27 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1822,6 +1822,35 @@ static inline unsigned long cpu_util_est(int cpu) }
unsigned long boosted_cpu_util(int cpu); + +/** + * __cpu_util_sum: get summed utilization for the specified CPU + * @cpu: the CPU to get the summed utilization for + * + * According to the passed parameter for RT utilization and CFS + * utilization to calculate the sum utilization for the CPU. The WALT + * signal has includes CFS/RT/DL classes utilization, so directly + * return back the utilization value; PELT signal will accumulate RT/DL + * and CFS utilization. + * + * Return: the summed utilization for the specified CPU + */ +static inline unsigned long __cpu_util_sum(int cpu, unsigned long rt_util, + unsigned long cfs_util) +{ +#ifdef CONFIG_SCHED_WALT + if (!walt_disabled && sysctl_sched_use_walt_cpu_util) + return cfs_util; +#endif + return (rt_util + cfs_util); +} + +static inline unsigned long cpu_util_sum(int cpu) +{ + struct rq *rq = cpu_rq(cpu); + + return __cpu_util_sum(cpu, rq->rt.avg.util_avg, boosted_cpu_util(cpu)); +} #endif
#ifdef CONFIG_CPU_FREQ_GOV_SCHED -- 1.9.1