提交 c1aa905a 编写于 作者: L Linus Torvalds

Merge tag 'pm-4.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management fixes from Rafael Wysocki:
 "These fix several issues in the intel_pstate driver and one issue in
  the schedutil cpufreq governor, clean up that governor a bit and hook
  up existing code for disabling cpufreq to a new kernel command line
  option.

  Specifics:

   - Three fixes for intel_pstate problems related to the passive mode
     (in which it acts as a regular cpufreq scaling driver), two for the
     handling of global P-state limits and one for the handling of the
     cpu_frequency tracepoint in that mode (Rafael Wysocki).

   - Three fixes for the handling of P-state limits in intel_pstate in
     the active mode (Rafael Wysocki).

   - Introduction of a new cpufreq.off=1 kernel command line argument
     that will disable cpufreq entirely if passed to the kernel and is
     simply hooked up to the existing code used by Xen (Len Brown).

   - Fix for the schedutil cpufreq governor to prevent it from using
     stale raw frequency values in configurations with mutiple CPUs
     sharing one policy object and a cleanup for it reducing its
     overhead slightly (Viresh Kumar)"

* tag 'pm-4.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  cpufreq: intel_pstate: Do not reinit performance limits in ->setpolicy
  cpufreq: intel_pstate: Fix intel_pstate_verify_policy()
  cpufreq: intel_pstate: Fix global settings in active mode
  cpufreq: Add the "cpufreq.off=1" cmdline option
  cpufreq: schedutil: Pass sg_policy to get_next_freq()
  cpufreq: schedutil: move cached_raw_freq to struct sugov_policy
  cpufreq: intel_pstate: Avoid triggering cpu_frequency tracepoint unnecessarily
  cpufreq: intel_pstate: Fix intel_cpufreq_verify_policy()
  cpufreq: intel_pstate: Do not use performance_limits in passive mode
...@@ -653,6 +653,9 @@ ...@@ -653,6 +653,9 @@
cpuidle.off=1 [CPU_IDLE] cpuidle.off=1 [CPU_IDLE]
disable the cpuidle sub-system disable the cpuidle sub-system
cpufreq.off=1 [CPU_FREQ]
disable the cpufreq sub-system
cpu_init_udelay=N cpu_init_udelay=N
[X86] Delay for N microsec between assert and de-assert [X86] Delay for N microsec between assert and de-assert
of APIC INIT to start processors. This delay occurs of APIC INIT to start processors. This delay occurs
......
...@@ -2532,4 +2532,5 @@ static int __init cpufreq_core_init(void) ...@@ -2532,4 +2532,5 @@ static int __init cpufreq_core_init(void)
return 0; return 0;
} }
module_param(off, int, 0444);
core_initcall(cpufreq_core_init); core_initcall(cpufreq_core_init);
...@@ -377,6 +377,7 @@ static void intel_pstate_set_performance_limits(struct perf_limits *limits) ...@@ -377,6 +377,7 @@ static void intel_pstate_set_performance_limits(struct perf_limits *limits)
intel_pstate_init_limits(limits); intel_pstate_init_limits(limits);
limits->min_perf_pct = 100; limits->min_perf_pct = 100;
limits->min_perf = int_ext_tofp(1); limits->min_perf = int_ext_tofp(1);
limits->min_sysfs_pct = 100;
} }
static DEFINE_MUTEX(intel_pstate_driver_lock); static DEFINE_MUTEX(intel_pstate_driver_lock);
...@@ -968,11 +969,20 @@ static int intel_pstate_resume(struct cpufreq_policy *policy) ...@@ -968,11 +969,20 @@ static int intel_pstate_resume(struct cpufreq_policy *policy)
} }
static void intel_pstate_update_policies(void) static void intel_pstate_update_policies(void)
__releases(&intel_pstate_limits_lock)
__acquires(&intel_pstate_limits_lock)
{ {
struct perf_limits *saved_limits = limits;
int cpu; int cpu;
mutex_unlock(&intel_pstate_limits_lock);
for_each_possible_cpu(cpu) for_each_possible_cpu(cpu)
cpufreq_update_policy(cpu); cpufreq_update_policy(cpu);
mutex_lock(&intel_pstate_limits_lock);
limits = saved_limits;
} }
/************************** debugfs begin ************************/ /************************** debugfs begin ************************/
...@@ -1180,10 +1190,10 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, ...@@ -1180,10 +1190,10 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b,
limits->no_turbo = clamp_t(int, input, 0, 1); limits->no_turbo = clamp_t(int, input, 0, 1);
mutex_unlock(&intel_pstate_limits_lock);
intel_pstate_update_policies(); intel_pstate_update_policies();
mutex_unlock(&intel_pstate_limits_lock);
mutex_unlock(&intel_pstate_driver_lock); mutex_unlock(&intel_pstate_driver_lock);
return count; return count;
...@@ -1217,10 +1227,10 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b, ...@@ -1217,10 +1227,10 @@ static ssize_t store_max_perf_pct(struct kobject *a, struct attribute *b,
limits->max_perf_pct); limits->max_perf_pct);
limits->max_perf = div_ext_fp(limits->max_perf_pct, 100); limits->max_perf = div_ext_fp(limits->max_perf_pct, 100);
mutex_unlock(&intel_pstate_limits_lock);
intel_pstate_update_policies(); intel_pstate_update_policies();
mutex_unlock(&intel_pstate_limits_lock);
mutex_unlock(&intel_pstate_driver_lock); mutex_unlock(&intel_pstate_driver_lock);
return count; return count;
...@@ -1254,10 +1264,10 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b, ...@@ -1254,10 +1264,10 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
limits->min_perf_pct); limits->min_perf_pct);
limits->min_perf = div_ext_fp(limits->min_perf_pct, 100); limits->min_perf = div_ext_fp(limits->min_perf_pct, 100);
mutex_unlock(&intel_pstate_limits_lock);
intel_pstate_update_policies(); intel_pstate_update_policies();
mutex_unlock(&intel_pstate_limits_lock);
mutex_unlock(&intel_pstate_driver_lock); mutex_unlock(&intel_pstate_driver_lock);
return count; return count;
...@@ -1874,13 +1884,11 @@ static int intel_pstate_prepare_request(struct cpudata *cpu, int pstate) ...@@ -1874,13 +1884,11 @@ static int intel_pstate_prepare_request(struct cpudata *cpu, int pstate)
intel_pstate_get_min_max(cpu, &min_perf, &max_perf); intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
pstate = clamp_t(int, pstate, min_perf, max_perf); pstate = clamp_t(int, pstate, min_perf, max_perf);
trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu);
return pstate; return pstate;
} }
static void intel_pstate_update_pstate(struct cpudata *cpu, int pstate) static void intel_pstate_update_pstate(struct cpudata *cpu, int pstate)
{ {
pstate = intel_pstate_prepare_request(cpu, pstate);
if (pstate == cpu->pstate.current_pstate) if (pstate == cpu->pstate.current_pstate)
return; return;
...@@ -1900,6 +1908,8 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu) ...@@ -1900,6 +1908,8 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
update_turbo_state(); update_turbo_state();
target_pstate = intel_pstate_prepare_request(cpu, target_pstate);
trace_cpu_frequency(target_pstate * cpu->pstate.scaling, cpu->cpu);
intel_pstate_update_pstate(cpu, target_pstate); intel_pstate_update_pstate(cpu, target_pstate);
sample = &cpu->sample; sample = &cpu->sample;
...@@ -2132,16 +2142,11 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) ...@@ -2132,16 +2142,11 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
mutex_lock(&intel_pstate_limits_lock); mutex_lock(&intel_pstate_limits_lock);
if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
pr_debug("set performance\n");
if (!perf_limits) { if (!perf_limits) {
limits = &performance_limits; limits = &performance_limits;
perf_limits = limits; perf_limits = limits;
} }
if (policy->max >= policy->cpuinfo.max_freq &&
!limits->no_turbo) {
pr_debug("set performance\n");
intel_pstate_set_performance_limits(perf_limits);
goto out;
}
} else { } else {
pr_debug("set powersave\n"); pr_debug("set powersave\n");
if (!perf_limits) { if (!perf_limits) {
...@@ -2152,7 +2157,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) ...@@ -2152,7 +2157,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
} }
intel_pstate_update_perf_limits(policy, perf_limits); intel_pstate_update_perf_limits(policy, perf_limits);
out:
if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) { if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) {
/* /*
* NOHZ_FULL CPUs need this as the governor callback may not * NOHZ_FULL CPUs need this as the governor callback may not
...@@ -2198,9 +2203,9 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy) ...@@ -2198,9 +2203,9 @@ static int intel_pstate_verify_policy(struct cpufreq_policy *policy)
unsigned int max_freq, min_freq; unsigned int max_freq, min_freq;
max_freq = policy->cpuinfo.max_freq * max_freq = policy->cpuinfo.max_freq *
limits->max_sysfs_pct / 100; perf_limits->max_sysfs_pct / 100;
min_freq = policy->cpuinfo.max_freq * min_freq = policy->cpuinfo.max_freq *
limits->min_sysfs_pct / 100; perf_limits->min_sysfs_pct / 100;
cpufreq_verify_within_limits(policy, min_freq, max_freq); cpufreq_verify_within_limits(policy, min_freq, max_freq);
} }
...@@ -2243,13 +2248,8 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy) ...@@ -2243,13 +2248,8 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy)
cpu = all_cpu_data[policy->cpu]; cpu = all_cpu_data[policy->cpu];
/*
* We need sane value in the cpu->perf_limits, so inherit from global
* perf_limits limits, which are seeded with values based on the
* CONFIG_CPU_FREQ_DEFAULT_GOV_*, during boot up.
*/
if (per_cpu_limits) if (per_cpu_limits)
memcpy(cpu->perf_limits, limits, sizeof(struct perf_limits)); intel_pstate_init_limits(cpu->perf_limits);
policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling;
policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling;
...@@ -2301,7 +2301,6 @@ static struct cpufreq_driver intel_pstate = { ...@@ -2301,7 +2301,6 @@ static struct cpufreq_driver intel_pstate = {
static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy)
{ {
struct cpudata *cpu = all_cpu_data[policy->cpu]; struct cpudata *cpu = all_cpu_data[policy->cpu];
struct perf_limits *perf_limits = limits;
update_turbo_state(); update_turbo_state();
policy->cpuinfo.max_freq = limits->turbo_disabled ? policy->cpuinfo.max_freq = limits->turbo_disabled ?
...@@ -2309,15 +2308,6 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) ...@@ -2309,15 +2308,6 @@ static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy)
cpufreq_verify_within_cpu_limits(policy); cpufreq_verify_within_cpu_limits(policy);
if (per_cpu_limits)
perf_limits = cpu->perf_limits;
mutex_lock(&intel_pstate_limits_lock);
intel_pstate_update_perf_limits(policy, perf_limits);
mutex_unlock(&intel_pstate_limits_lock);
return 0; return 0;
} }
...@@ -2370,6 +2360,7 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy, ...@@ -2370,6 +2360,7 @@ static int intel_cpufreq_target(struct cpufreq_policy *policy,
wrmsrl_on_cpu(policy->cpu, MSR_IA32_PERF_CTL, wrmsrl_on_cpu(policy->cpu, MSR_IA32_PERF_CTL,
pstate_funcs.get_val(cpu, target_pstate)); pstate_funcs.get_val(cpu, target_pstate));
} }
freqs.new = target_pstate * cpu->pstate.scaling;
cpufreq_freq_transition_end(policy, &freqs, false); cpufreq_freq_transition_end(policy, &freqs, false);
return 0; return 0;
...@@ -2383,8 +2374,9 @@ static unsigned int intel_cpufreq_fast_switch(struct cpufreq_policy *policy, ...@@ -2383,8 +2374,9 @@ static unsigned int intel_cpufreq_fast_switch(struct cpufreq_policy *policy,
target_freq = intel_cpufreq_turbo_update(cpu, policy, target_freq); target_freq = intel_cpufreq_turbo_update(cpu, policy, target_freq);
target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling);
target_pstate = intel_pstate_prepare_request(cpu, target_pstate);
intel_pstate_update_pstate(cpu, target_pstate); intel_pstate_update_pstate(cpu, target_pstate);
return target_freq; return target_pstate * cpu->pstate.scaling;
} }
static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy) static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy)
...@@ -2437,8 +2429,11 @@ static int intel_pstate_register_driver(void) ...@@ -2437,8 +2429,11 @@ static int intel_pstate_register_driver(void)
intel_pstate_init_limits(&powersave_limits); intel_pstate_init_limits(&powersave_limits);
intel_pstate_set_performance_limits(&performance_limits); intel_pstate_set_performance_limits(&performance_limits);
limits = IS_ENABLED(CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE) ? if (IS_ENABLED(CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE) &&
&performance_limits : &powersave_limits; intel_pstate_driver == &intel_pstate)
limits = &performance_limits;
else
limits = &powersave_limits;
ret = cpufreq_register_driver(intel_pstate_driver); ret = cpufreq_register_driver(intel_pstate_driver);
if (ret) { if (ret) {
......
...@@ -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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册