Commit 32d3b06a authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branch 'pm-cpufreq-sched'

* pm-cpufreq-sched:
  cpufreq: schedutil: Pass sg_policy to get_next_freq()
  cpufreq: schedutil: move cached_raw_freq to struct sugov_policy
parents fd8e57d5 655cb1eb
...@@ -36,6 +36,7 @@ struct sugov_policy { ...@@ -36,6 +36,7 @@ struct sugov_policy {
u64 last_freq_update_time; u64 last_freq_update_time;
s64 freq_update_delay_ns; s64 freq_update_delay_ns;
unsigned int next_freq; unsigned int next_freq;
unsigned int cached_raw_freq;
/* The next fields are only needed if fast switch cannot be used. */ /* The next fields are only needed if fast switch cannot be used. */
struct irq_work irq_work; struct irq_work irq_work;
...@@ -52,7 +53,6 @@ struct sugov_cpu { ...@@ -52,7 +53,6 @@ struct sugov_cpu {
struct update_util_data update_util; struct update_util_data update_util;
struct sugov_policy *sg_policy; struct sugov_policy *sg_policy;
unsigned int cached_raw_freq;
unsigned long iowait_boost; unsigned long iowait_boost;
unsigned long iowait_boost_max; unsigned long iowait_boost_max;
u64 last_update; u64 last_update;
...@@ -116,7 +116,7 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, ...@@ -116,7 +116,7 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
/** /**
* get_next_freq - Compute a new frequency for a given cpufreq policy. * get_next_freq - Compute a new frequency for a given cpufreq policy.
* @sg_cpu: schedutil cpu object to compute the new frequency for. * @sg_policy: schedutil policy object to compute the new frequency for.
* @util: Current CPU utilization. * @util: Current CPU utilization.
* @max: CPU capacity. * @max: CPU capacity.
* *
...@@ -136,19 +136,18 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time, ...@@ -136,19 +136,18 @@ static void sugov_update_commit(struct sugov_policy *sg_policy, u64 time,
* next_freq (as calculated above) is returned, subject to policy min/max and * next_freq (as calculated above) is returned, subject to policy min/max and
* cpufreq driver limitations. * cpufreq driver limitations.
*/ */
static unsigned int get_next_freq(struct sugov_cpu *sg_cpu, unsigned long util, static unsigned int get_next_freq(struct sugov_policy *sg_policy,
unsigned long max) unsigned long util, unsigned long max)
{ {
struct sugov_policy *sg_policy = sg_cpu->sg_policy;
struct cpufreq_policy *policy = sg_policy->policy; struct cpufreq_policy *policy = sg_policy->policy;
unsigned int freq = arch_scale_freq_invariant() ? unsigned int freq = arch_scale_freq_invariant() ?
policy->cpuinfo.max_freq : policy->cur; policy->cpuinfo.max_freq : policy->cur;
freq = (freq + (freq >> 2)) * util / max; freq = (freq + (freq >> 2)) * util / max;
if (freq == sg_cpu->cached_raw_freq && sg_policy->next_freq != UINT_MAX) if (freq == sg_policy->cached_raw_freq && sg_policy->next_freq != UINT_MAX)
return sg_policy->next_freq; return sg_policy->next_freq;
sg_cpu->cached_raw_freq = freq; sg_policy->cached_raw_freq = freq;
return cpufreq_driver_resolve_freq(policy, freq); return cpufreq_driver_resolve_freq(policy, freq);
} }
...@@ -213,7 +212,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, ...@@ -213,7 +212,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time,
} else { } else {
sugov_get_util(&util, &max); sugov_get_util(&util, &max);
sugov_iowait_boost(sg_cpu, &util, &max); sugov_iowait_boost(sg_cpu, &util, &max);
next_f = get_next_freq(sg_cpu, util, max); next_f = get_next_freq(sg_policy, util, max);
} }
sugov_update_commit(sg_policy, time, next_f); sugov_update_commit(sg_policy, time, next_f);
} }
...@@ -267,7 +266,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, ...@@ -267,7 +266,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu,
sugov_iowait_boost(j_sg_cpu, &util, &max); sugov_iowait_boost(j_sg_cpu, &util, &max);
} }
return get_next_freq(sg_cpu, util, max); return get_next_freq(sg_policy, util, max);
} }
static void sugov_update_shared(struct update_util_data *hook, u64 time, static void sugov_update_shared(struct update_util_data *hook, u64 time,
...@@ -580,6 +579,7 @@ static int sugov_start(struct cpufreq_policy *policy) ...@@ -580,6 +579,7 @@ static int sugov_start(struct cpufreq_policy *policy)
sg_policy->next_freq = UINT_MAX; sg_policy->next_freq = UINT_MAX;
sg_policy->work_in_progress = false; sg_policy->work_in_progress = false;
sg_policy->need_freq_update = false; sg_policy->need_freq_update = false;
sg_policy->cached_raw_freq = 0;
for_each_cpu(cpu, policy->cpus) { for_each_cpu(cpu, policy->cpus) {
struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu); struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu);
...@@ -590,7 +590,6 @@ static int sugov_start(struct cpufreq_policy *policy) ...@@ -590,7 +590,6 @@ static int sugov_start(struct cpufreq_policy *policy)
sg_cpu->max = 0; sg_cpu->max = 0;
sg_cpu->flags = SCHED_CPUFREQ_RT; sg_cpu->flags = SCHED_CPUFREQ_RT;
sg_cpu->last_update = 0; sg_cpu->last_update = 0;
sg_cpu->cached_raw_freq = 0;
sg_cpu->iowait_boost = 0; sg_cpu->iowait_boost = 0;
sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq; sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq;
cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment