diff mbox series

sched: cpufreq_schedutil: restore cached freq when next_f is not changed

Message ID 20201016181722.884812-1-wvw@google.com
State New
Headers show
Series sched: cpufreq_schedutil: restore cached freq when next_f is not changed | expand

Commit Message

Wei Wang Oct. 16, 2020, 6:17 p.m. UTC
We have the raw cached freq to reduce the chance in calling cpufreq
driver where it could be costly in some arch/SoC.

Currently, the raw cached freq will be reset when next_f is changed for
correctness. This patch changes it to maintain the cached value instead
of dropping it to honor the purpose of the cached value.

This is adapted from https://android-review.googlesource.com/1352810/

Signed-off-by: Wei Wang <wvw@google.com>

---
 kernel/sched/cpufreq_schedutil.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.29.0.rc1.297.gfa9743e501-goog

Comments

Viresh Kumar Oct. 19, 2020, 5:09 a.m. UTC | #1
On 16-10-20, 11:17, Wei Wang wrote:
> We have the raw cached freq to reduce the chance in calling cpufreq

> driver where it could be costly in some arch/SoC.

> 

> Currently, the raw cached freq will be reset when next_f is changed for

> correctness. This patch changes it to maintain the cached value instead

> of dropping it to honor the purpose of the cached value.

> 

> This is adapted from https://android-review.googlesource.com/1352810/

> 

> Signed-off-by: Wei Wang <wvw@google.com>

> ---

>  kernel/sched/cpufreq_schedutil.c | 5 +++--

>  1 file changed, 3 insertions(+), 2 deletions(-)

> 

> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c

> index 5ae7b4e6e8d6..e254745a82cb 100644

> --- a/kernel/sched/cpufreq_schedutil.c

> +++ b/kernel/sched/cpufreq_schedutil.c

> @@ -441,6 +441,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,

>  	unsigned long util, max;

>  	unsigned int next_f;

>  	bool busy;

> +	unsigned int cached_freq = sg_policy->cached_raw_freq;

>  

>  	sugov_iowait_boost(sg_cpu, time, flags);

>  	sg_cpu->last_update = time;

> @@ -464,8 +465,8 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,

>  	if (busy && next_f < sg_policy->next_freq) {

>  		next_f = sg_policy->next_freq;

>  

> -		/* Reset cached freq as next_freq has changed */

> -		sg_policy->cached_raw_freq = 0;

> +		/* Restore cached freq as next_freq has changed */

> +		sg_policy->cached_raw_freq = cached_freq;

>  	}

>  

>  	/*


Acked-by: Viresh Kumar <viresh.kumar@linaro.org>


-- 
viresh
Rafael J. Wysocki Oct. 19, 2020, 3:39 p.m. UTC | #2
On Fri, Oct 16, 2020 at 8:17 PM Wei Wang <wvw@google.com> wrote:
>

> We have the raw cached freq to reduce the chance in calling cpufreq

> driver where it could be costly in some arch/SoC.

>

> Currently, the raw cached freq will be reset when next_f is changed for

> correctness. This patch changes it to maintain the cached value instead

> of dropping it to honor the purpose of the cached value.

>

> This is adapted from https://android-review.googlesource.com/1352810/

>

> Signed-off-by: Wei Wang <wvw@google.com>

> ---

>  kernel/sched/cpufreq_schedutil.c | 5 +++--

>  1 file changed, 3 insertions(+), 2 deletions(-)

>

> diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c

> index 5ae7b4e6e8d6..e254745a82cb 100644

> --- a/kernel/sched/cpufreq_schedutil.c

> +++ b/kernel/sched/cpufreq_schedutil.c

> @@ -441,6 +441,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,

>         unsigned long util, max;

>         unsigned int next_f;

>         bool busy;

> +       unsigned int cached_freq = sg_policy->cached_raw_freq;

>

>         sugov_iowait_boost(sg_cpu, time, flags);

>         sg_cpu->last_update = time;

> @@ -464,8 +465,8 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,

>         if (busy && next_f < sg_policy->next_freq) {

>                 next_f = sg_policy->next_freq;

>

> -               /* Reset cached freq as next_freq has changed */

> -               sg_policy->cached_raw_freq = 0;

> +               /* Restore cached freq as next_freq has changed */

> +               sg_policy->cached_raw_freq = cached_freq;

>         }

>

>         /*

> --


Applied as 5.10-rc material with edited subject and rewritten changelog.

Thanks!
diff mbox series

Patch

diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index 5ae7b4e6e8d6..e254745a82cb 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -441,6 +441,7 @@  static void sugov_update_single(struct update_util_data *hook, u64 time,
 	unsigned long util, max;
 	unsigned int next_f;
 	bool busy;
+	unsigned int cached_freq = sg_policy->cached_raw_freq;
 
 	sugov_iowait_boost(sg_cpu, time, flags);
 	sg_cpu->last_update = time;
@@ -464,8 +465,8 @@  static void sugov_update_single(struct update_util_data *hook, u64 time,
 	if (busy && next_f < sg_policy->next_freq) {
 		next_f = sg_policy->next_freq;
 
-		/* Reset cached freq as next_freq has changed */
-		sg_policy->cached_raw_freq = 0;
+		/* Restore cached freq as next_freq has changed */
+		sg_policy->cached_raw_freq = cached_freq;
 	}
 
 	/*