cpufreq: Correct the data reported in all_time_in_state

Commit 448a5242bddb ("cpufreq_stats:Adds the fucntionality
to load current values for each frequency for all the cores")
introduced a change by which'cpufreq_allstats_create' gets
called at initialization (from 'cpufreq_stats_init' instead
of 'cpufreq_stat_notifier_policy'). This causes
'cpufreq_allstate_create' to be called before the freq_table
is allocated from 'create_all_freq_table'. Due to this, the
data for cpu's which are online at boot are not added to the
'all_freq_table' leading to the incorrect reporting of data
when the below sysfs command is run
- 'cat sys/devices/system/cpu/cpufreq/all_time_in_state'.

Correct this behaviour by altering the cpufreq_stats init
sequence by which the memory for 'all_freq_table' is allocated
before the 'cpufreq_allstats_create' function is called.

Change-Id: I2232dacdc0deec4d1987c418e833fe28f74623fc
Signed-off-by: Nirmal Abraham <nabrah@codeaurora.org>
Signed-off-by: Avaneesh Kumar Dwivedi <akdwived@codeaurora.org>
This commit is contained in:
Nirmal Abraham 2015-10-07 16:23:43 +05:30 committed by Avaneesh Kumar Dwivedi
parent 4b5e09f6d1
commit 22881ffe61
1 changed files with 14 additions and 1 deletions

View File

@ -331,6 +331,7 @@ static void cpufreq_allstats_free(void)
kfree(all_stat);
per_cpu(all_cpufreq_stats, cpu) = NULL;
}
if (all_freq_table) {
kfree(all_freq_table->freq_table);
kfree(all_freq_table);
@ -512,6 +513,16 @@ static void create_all_freq_table(void)
return;
}
static void free_all_freq_table(void)
{
if (all_freq_table) {
kfree(all_freq_table->freq_table);
all_freq_table->freq_table = NULL;
kfree(all_freq_table);
all_freq_table = NULL;
}
}
static void add_all_freq_table(unsigned int freq)
{
unsigned int size;
@ -700,6 +711,8 @@ static int __init cpufreq_stats_init(void)
if (ret)
return ret;
create_all_freq_table();
for_each_online_cpu(cpu)
cpufreq_stats_create_table(cpu);
@ -710,10 +723,10 @@ static int __init cpufreq_stats_init(void)
CPUFREQ_POLICY_NOTIFIER);
for_each_online_cpu(cpu)
cpufreq_stats_free_table(cpu);
free_all_freq_table();
return ret;
}
create_all_freq_table();
ret = cpufreq_sysfs_create_file(&_attr_all_time_in_state.attr);
if (ret)
pr_warn("Cannot create sysfs file for cpufreq stats\n");