From ae4b838fa6c7b1eee97436bb88f3de0ba6f1d3ea Mon Sep 17 00:00:00 2001 From: Alfred Chen Date: Sun, 14 Mar 2021 17:28:24 +0800 Subject: [PATCH] sched/alt: Fix limited cpufreq for schedutil. Here is the first fix for #12, which fix the limited cpufreq for schedutil. But it still tend to stay at max cpufreq. --- kernel/sched/alt_sched.h | 3 ++- kernel/sched/cpufreq_schedutil.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/kernel/sched/alt_sched.h b/kernel/sched/alt_sched.h index 51f11bf416f41c..7bcd96cc6bedad 100644 --- a/kernel/sched/alt_sched.h +++ b/kernel/sched/alt_sched.h @@ -598,7 +598,8 @@ static inline void cpufreq_update_util(struct rq *rq, unsigned int flags) { struct update_util_data *data; - data = rcu_dereference_sched(*this_cpu_ptr(&cpufreq_update_util_data)); + data = rcu_dereference_sched(*per_cpu_ptr(&cpufreq_update_util_data, + cpu_of(rq))); if (data) data->func(data, rq_clock(rq), flags); } diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index fbdfa15b059589..1663a49b127eeb 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -207,11 +207,16 @@ static void sugov_get_util(struct sugov_cpu *sg_cpu, unsigned long boost) sg_cpu->bw_min = min; sg_cpu->util = sugov_effective_cpu_perf(sg_cpu->cpu, util, min, max); } + #else /* CONFIG_SCHED_ALT */ -static unsigned long sugov_get_util(struct sugov_cpu *sg_cpu) + +static void sugov_get_util(struct sugov_cpu *sg_cpu) { - sg_cpu->max = arch_scale_cpu_capacity(sg_cpu->cpu); - return sg_cpu->max; + unsigned long max = arch_scale_cpu_capacity(sg_cpu->cpu); + + sg_cpu->max = max; + sg_cpu->bw_dl = 0; + sg_cpu->util = cpu_rq(sg_cpu->cpu)->nr_running ? max:0UL; } #endif @@ -374,8 +379,8 @@ static inline void ignore_dl_rate_limit(struct sugov_cpu *sg_cpu) { #ifndef CONFIG_SCHED_ALT if (cpu_bw_dl(cpu_rq(sg_cpu->cpu)) > sg_cpu->bw_min) -#endif sg_cpu->sg_policy->limits_changed = true; +#endif } static inline bool sugov_update_single_common(struct sugov_cpu *sg_cpu,