From: Ruchi Kandoi Date: Sat, 6 Jun 2015 01:21:56 +0000 (-0700) Subject: cpufreq: Iterate over all the possible cpus to create powerstats. X-Git-Tag: firefly_0821_release~3678^2~26 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9b48fbb68580872b5be9d25a3d47189da6089bdc;p=firefly-linux-kernel-4.4.55.git 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 (cherry picked from commit 5862c50d1970886b5b5a57b5b52ecfd6feb95ebd) --- diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 4bb1ec49cb27..2433e404721a 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c @@ -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);