diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2015-05-12 12:22:12 +0530 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2015-05-15 02:38:18 +0200 |
commit | 9104bb26c740cd4b2c9ee927f3caabbde0414558 (patch) | |
tree | 5852c9111d6d152c5f12b01d08ffd6c6e26b902e /drivers | |
parent | 3914d37910af2cd0cc992ae546b8308e05759d2b (diff) | |
download | linux-stable-9104bb26c740cd4b2c9ee927f3caabbde0414558.tar.gz linux-stable-9104bb26c740cd4b2c9ee927f3caabbde0414558.tar.bz2 linux-stable-9104bb26c740cd4b2c9ee927f3caabbde0414558.zip |
cpufreq: Don't traverse all active policies to find policy for a cpu
We reach here while adding policy for a CPU and enter into the 'if'
block only if a policy already exists for the CPU.
As cpufreq_cpu_data is set for all policy->related_cpus now, when the
policy is first added, we can use that to find the CPU's policy instead
of traversing the list of all active policies.
Acked-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index eb0c3a802b14..e6a63d6ba6f1 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1213,16 +1213,13 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) return 0; /* Check if this CPU already has a policy to manage it */ - read_lock_irqsave(&cpufreq_driver_lock, flags); - for_each_active_policy(policy) { - if (cpumask_test_cpu(cpu, policy->related_cpus)) { - read_unlock_irqrestore(&cpufreq_driver_lock, flags); - ret = cpufreq_add_policy_cpu(policy, cpu, dev); - up_read(&cpufreq_rwsem); - return ret; - } + policy = per_cpu(cpufreq_cpu_data, cpu); + if (policy && !policy_is_inactive(policy)) { + WARN_ON(!cpumask_test_cpu(cpu, policy->related_cpus)); + ret = cpufreq_add_policy_cpu(policy, cpu, dev); + up_read(&cpufreq_rwsem); + return ret; } - read_unlock_irqrestore(&cpufreq_driver_lock, flags); /* * Restore the saved policy when doing light-weight init and fall back |