* [PATCH 0/3] cpufreq: intel_pstate: Fixes related to the passive mode
@ 2017-03-02 22:20 Rafael J. Wysocki
2017-03-02 22:22 ` [PATCH 1/3] cpufreq: intel_pstate: Do not use performance_limits in " Rafael J. Wysocki
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2017-03-02 22:20 UTC (permalink / raw)
To: Linux PM; +Cc: LKML, Srinivas Pandruvada
Hi,
This series fixes some passive mode behavior related to limits and the
cpu_frequency tracepoint.
It depends on https://patchwork.kernel.org/patch/9594447/ (which is in
linux-next already), but it doesn't depend on the other series I posted
yesterday (https://patchwork.kernel.org/patch/9597147/ ,
https://patchwork.kernel.org/patch/9597145/,
https://patchwork.kernel.org/patch/9597137/).
All three patches in this series are reasonably straightforward and should
not be controversial. Also they should affect the passive mode only.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 1/3] cpufreq: intel_pstate: Do not use performance_limits in passive mode 2017-03-02 22:20 [PATCH 0/3] cpufreq: intel_pstate: Fixes related to the passive mode Rafael J. Wysocki @ 2017-03-02 22:22 ` Rafael J. Wysocki 2017-03-02 22:24 ` [PATCH 2/3] cpufreq: intel_pstate: Fix intel_cpufreq_verify_policy() Rafael J. Wysocki 2017-03-02 22:26 ` [PATCH 3/3] cpufreq: intel_pstate: Avoid triggering cpu_frequency tracepoint unnecessarily Rafael J. Wysocki 2 siblings, 0 replies; 5+ messages in thread From: Rafael J. Wysocki @ 2017-03-02 22:22 UTC (permalink / raw) To: Linux PM; +Cc: LKML, Srinivas Pandruvada From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Using performance_limits in the passive mode doesn't make sense, because in that mode the global limits are applied to the frequency selected by the scaling governor. The maximum and minimum P-state limits in performance_limits are both set to 100 percent which will put all CPUs into the turbo range regardless of what governor is used and what frequencies are selected by it (that is particularly undesirable on CPUs with the generic powersave governor attached). For this reason, make intel_pstate_register_driver() always point limits to powersave_limits in the passive mode. Fixes: 001c76f05b01 (cpufreq: intel_pstate: Generic governors support) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- drivers/cpufreq/intel_pstate.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -2442,8 +2442,11 @@ static int intel_pstate_register_driver( intel_pstate_init_limits(&powersave_limits); intel_pstate_set_performance_limits(&performance_limits); - limits = IS_ENABLED(CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE) ? - &performance_limits : &powersave_limits; + if (IS_ENABLED(CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE) && + intel_pstate_driver == &intel_pstate) + limits = &performance_limits; + else + limits = &powersave_limits; ret = cpufreq_register_driver(intel_pstate_driver); if (ret) { ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] cpufreq: intel_pstate: Fix intel_cpufreq_verify_policy() 2017-03-02 22:20 [PATCH 0/3] cpufreq: intel_pstate: Fixes related to the passive mode Rafael J. Wysocki 2017-03-02 22:22 ` [PATCH 1/3] cpufreq: intel_pstate: Do not use performance_limits in " Rafael J. Wysocki @ 2017-03-02 22:24 ` Rafael J. Wysocki 2017-03-02 22:26 ` [PATCH 3/3] cpufreq: intel_pstate: Avoid triggering cpu_frequency tracepoint unnecessarily Rafael J. Wysocki 2 siblings, 0 replies; 5+ messages in thread From: Rafael J. Wysocki @ 2017-03-02 22:24 UTC (permalink / raw) To: Linux PM; +Cc: LKML, Srinivas Pandruvada From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> The intel_pstate_update_perf_limits() called from intel_cpufreq_verify_policy() may cause global P-state limits to change which is generally confusing and unnecessary. In the passive mode the global limits are only applied to the frequency selected by the scaling governor (they are not taken into account by governors when making decisions anyway), so making them follow the per-policy limits serves no purpose and may go against user expectations (as it generally causes the global attributes in sysfs to change even though they have not been written to in some cases). Fix that by dropping the intel_pstate_update_perf_limits() invocation from intel_cpufreq_verify_policy() (which also reduces the code size by a few lines). This change does not affect the per-CPU limits case, because those limits allow any P-state to be set by default in the passive mode and it removes the only piece of code updating them in that mode, so the per-policy settings will be the only ones taken into account in that case as expected. Fixes: 001c76f05b01 (cpufreq: intel_pstate: Generic governors support) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- drivers/cpufreq/intel_pstate.c | 10 ---------- 1 file changed, 10 deletions(-) Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -2306,7 +2306,6 @@ static struct cpufreq_driver intel_pstat static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) { struct cpudata *cpu = all_cpu_data[policy->cpu]; - struct perf_limits *perf_limits = limits; update_turbo_state(); policy->cpuinfo.max_freq = limits->turbo_disabled ? @@ -2314,15 +2313,6 @@ static int intel_cpufreq_verify_policy(s 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; } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] cpufreq: intel_pstate: Avoid triggering cpu_frequency tracepoint unnecessarily 2017-03-02 22:20 [PATCH 0/3] cpufreq: intel_pstate: Fixes related to the passive mode Rafael J. Wysocki 2017-03-02 22:22 ` [PATCH 1/3] cpufreq: intel_pstate: Do not use performance_limits in " Rafael J. Wysocki 2017-03-02 22:24 ` [PATCH 2/3] cpufreq: intel_pstate: Fix intel_cpufreq_verify_policy() Rafael J. Wysocki @ 2017-03-02 22:26 ` Rafael J. Wysocki 2017-03-03 22:51 ` [Update][PATCH v2 " Rafael J. Wysocki 2 siblings, 1 reply; 5+ messages in thread From: Rafael J. Wysocki @ 2017-03-02 22:26 UTC (permalink / raw) To: Linux PM; +Cc: LKML, Srinivas Pandruvada From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> In the passive mode the cpu_frequency trace event is already triggered by the cpufreq core or by scaling governors, so intel_pstate should not trigger it once again for the same P-state updates. Fixes: 001c76f05b01 (cpufreq: intel_pstate: Generic governors support) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- drivers/cpufreq/intel_pstate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -1879,13 +1879,11 @@ static int intel_pstate_prepare_request( intel_pstate_get_min_max(cpu, &min_perf, &max_perf); pstate = clamp_t(int, pstate, min_perf, max_perf); - trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); return 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) return; @@ -1905,6 +1903,8 @@ static inline void intel_pstate_adjust_b 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); sample = &cpu->sample; @@ -2378,6 +2378,7 @@ static unsigned int intel_cpufreq_fast_s target_freq = intel_cpufreq_turbo_update(cpu, policy, target_freq); 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); return target_freq; } ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Update][PATCH v2 3/3] cpufreq: intel_pstate: Avoid triggering cpu_frequency tracepoint unnecessarily 2017-03-02 22:26 ` [PATCH 3/3] cpufreq: intel_pstate: Avoid triggering cpu_frequency tracepoint unnecessarily Rafael J. Wysocki @ 2017-03-03 22:51 ` Rafael J. Wysocki 0 siblings, 0 replies; 5+ messages in thread From: Rafael J. Wysocki @ 2017-03-03 22:51 UTC (permalink / raw) To: Linux PM; +Cc: LKML, Srinivas Pandruvada From: Rafael J. Wysocki <rafael.j.wysocki@intel.com> In the passive mode the cpu_frequency trace event is already triggered by the cpufreq core or by scaling governors, so intel_pstate should not trigger it once again for the same P-state updates. In addition to that, the frequency returned by intel_cpufreq_fast_switch() and passed via freqs.new from intel_cpufreq_target() to cpufreq_freq_transition_end() should reflect the P-state actually set, so make that happen. Fixes: 001c76f05b01 (cpufreq: intel_pstate: Generic governors support) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> --- -> v2: As mentioned in the changelog, the frequencies propagated to the caller of intel_cpufreq_fast_switch() and to cpufreq_freq_transition_end() should reflect the P-state that was set and not the requested frequency (which may be different due to the global limits, rounding etc). --- drivers/cpufreq/intel_pstate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) Index: linux-pm/drivers/cpufreq/intel_pstate.c =================================================================== --- linux-pm.orig/drivers/cpufreq/intel_pstate.c +++ linux-pm/drivers/cpufreq/intel_pstate.c @@ -1879,13 +1879,11 @@ static int intel_pstate_prepare_request( intel_pstate_get_min_max(cpu, &min_perf, &max_perf); pstate = clamp_t(int, pstate, min_perf, max_perf); - trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); return 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) return; @@ -1905,6 +1903,8 @@ static inline void intel_pstate_adjust_b 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); sample = &cpu->sample; @@ -2365,6 +2365,7 @@ static int intel_cpufreq_target(struct c wrmsrl_on_cpu(policy->cpu, MSR_IA32_PERF_CTL, pstate_funcs.get_val(cpu, target_pstate)); } + freqs.new = target_pstate * cpu->pstate.scaling; cpufreq_freq_transition_end(policy, &freqs, false); return 0; @@ -2378,8 +2379,9 @@ static unsigned int intel_cpufreq_fast_s target_freq = intel_cpufreq_turbo_update(cpu, policy, target_freq); 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); - return target_freq; + return target_pstate * cpu->pstate.scaling; } static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy) ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-03-03 23:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-03-02 22:20 [PATCH 0/3] cpufreq: intel_pstate: Fixes related to the passive mode Rafael J. Wysocki 2017-03-02 22:22 ` [PATCH 1/3] cpufreq: intel_pstate: Do not use performance_limits in " Rafael J. Wysocki 2017-03-02 22:24 ` [PATCH 2/3] cpufreq: intel_pstate: Fix intel_cpufreq_verify_policy() Rafael J. Wysocki 2017-03-02 22:26 ` [PATCH 3/3] cpufreq: intel_pstate: Avoid triggering cpu_frequency tracepoint unnecessarily Rafael J. Wysocki 2017-03-03 22:51 ` [Update][PATCH v2 " Rafael J. Wysocki
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®