cpufreq: Iterate over all the possible cpus to create powerstats.

For architectures which support a single policy for multiple cpus,
powerstats will not be initalized for all the cores. This change will
make sure powerstats is initialized for all the cores.

Also minor changes to increase code readability.

Bug: 21498425
Change-Id: I938f45e92ff6d5371c32c4d0e37274e6de66769c
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
(cherry picked from commit 5862c50d1970886b5b5a57b5b52ecfd6feb95ebd)
This commit is contained in:
Ruchi Kandoi
2015-06-05 18:21:56 -07:00
committed by Huang, Tao
parent f40cf81b65
commit 9b48fbb685

View File

@@ -604,7 +604,7 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
int ret, count = 0, i;
struct cpufreq_policy *policy = data;
struct cpufreq_frequency_table *table;
unsigned int cpu = policy->cpu;
unsigned int cpu_num, cpu = policy->cpu;
if (val == CPUFREQ_UPDATE_POLICY_CPU) {
cpufreq_stats_update_policy_cpu(policy);
@@ -628,8 +628,10 @@ static int cpufreq_stat_notifier_policy(struct notifier_block *nb,
if (!per_cpu(all_cpufreq_stats, cpu))
cpufreq_allstats_create(cpu, table, count);
if (!per_cpu(cpufreq_power_stats, cpu))
cpufreq_powerstats_create(cpu, table, count);
for_each_possible_cpu(cpu_num) {
if (!per_cpu(cpufreq_power_stats, cpu_num))
cpufreq_powerstats_create(cpu_num, table, count);
}
ret = cpufreq_stats_create_table(policy, table, count);
if (ret)
@@ -677,7 +679,7 @@ static int cpufreq_stats_create_table_cpu(unsigned int cpu)
{
struct cpufreq_policy *policy;
struct cpufreq_frequency_table *table;
int ret = -ENODEV, i, count = 0;
int i, count, cpu_num, ret = -ENODEV;
policy = cpufreq_cpu_get(cpu);
if (!policy)
@@ -687,19 +689,21 @@ static int cpufreq_stats_create_table_cpu(unsigned int cpu)
if (!table)
goto out;
count = 0;
for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {
unsigned int freq = table[i].frequency;
if (freq == CPUFREQ_ENTRY_INVALID)
continue;
count++;
if (freq != CPUFREQ_ENTRY_INVALID)
count++;
}
if (!per_cpu(all_cpufreq_stats, cpu))
cpufreq_allstats_create(cpu, table, count);
if (!per_cpu(cpufreq_power_stats, cpu))
cpufreq_powerstats_create(cpu, table, count);
for_each_possible_cpu(cpu_num) {
if (!per_cpu(cpufreq_power_stats, cpu_num))
cpufreq_powerstats_create(cpu_num, table, count);
}
ret = cpufreq_stats_create_table(policy, table, count);