linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: Call __cpufreq_governor() with correct policy->cpus mask
@ 2013-04-11  8:04 Viresh Kumar
  2013-04-11 21:34 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Viresh Kumar @ 2013-04-11  8:04 UTC (permalink / raw)
  To: rjw
  Cc: cpufreq, linux-pm, linux-kernel, robin.randhawa, Steve.Bannister,
	Liviu.Dudau, charles.garcia-tobin, arvind.chauhan, linaro-kernel,
	patches, Viresh Kumar

__cpufreq_governor() must be called with correct policy->cpus mask. In
__cpufreq_remove_dev() we initially clear policy->cpus with cpumask_clear_cpu()
and then call __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT). In case
governor is doing some per-cpu stuff in EXIT callback, this can create uncertain
behavior.

Generic governors in drivers/cpufreq/ doesn't do any per-cpu stuff in EXIT
callback and so we don't face any issues currently. But its better to keep the
code clean, so we don't face any issues in future.

Now, we call cpumask_clear_cpu() only when multiple cpus are managed by policy.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index fd97a62..3564947 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1105,7 +1105,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif
 
 	WARN_ON(lock_policy_rwsem_write(cpu));
 	cpus = cpumask_weight(data->cpus);
-	cpumask_clear_cpu(cpu, data->cpus);
+
+	if (cpus > 1)
+		cpumask_clear_cpu(cpu, data->cpus);
 	unlock_policy_rwsem_write(cpu);
 
 	if (cpu != data->cpu) {
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] cpufreq: Call __cpufreq_governor() with correct policy->cpus mask
  2013-04-11  8:04 [PATCH] cpufreq: Call __cpufreq_governor() with correct policy->cpus mask Viresh Kumar
@ 2013-04-11 21:34 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2013-04-11 21:34 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: cpufreq, linux-pm, linux-kernel, robin.randhawa, Steve.Bannister,
	Liviu.Dudau, charles.garcia-tobin, arvind.chauhan, linaro-kernel,
	patches

On Thursday, April 11, 2013 01:34:53 PM Viresh Kumar wrote:
> __cpufreq_governor() must be called with correct policy->cpus mask. In
> __cpufreq_remove_dev() we initially clear policy->cpus with cpumask_clear_cpu()
> and then call __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT). In case
> governor is doing some per-cpu stuff in EXIT callback, this can create uncertain
> behavior.
> 
> Generic governors in drivers/cpufreq/ doesn't do any per-cpu stuff in EXIT
> callback and so we don't face any issues currently. But its better to keep the
> code clean, so we don't face any issues in future.
> 
> Now, we call cpumask_clear_cpu() only when multiple cpus are managed by policy.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

Applied.

Thanks,
Rafael


> ---
>  drivers/cpufreq/cpufreq.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index fd97a62..3564947 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1105,7 +1105,9 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif
>  
>  	WARN_ON(lock_policy_rwsem_write(cpu));
>  	cpus = cpumask_weight(data->cpus);
> -	cpumask_clear_cpu(cpu, data->cpus);
> +
> +	if (cpus > 1)
> +		cpumask_clear_cpu(cpu, data->cpus);
>  	unlock_policy_rwsem_write(cpu);
>  
>  	if (cpu != data->cpu) {
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-11 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-11  8:04 [PATCH] cpufreq: Call __cpufreq_governor() with correct policy->cpus mask Viresh Kumar
2013-04-11 21:34 ` 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;
as well as URLs for NNTP newsgroup(s).