@@ -40,12 +40,10 @@ static int cpufreq_stats_update(struct cpufreq_stats *stat)
{
unsigned long long cur_time = get_jiffies_64();
- mutex_lock(&cpufreq_stats_lock);
if (stat->time_in_state)
stat->time_in_state[stat->last_index] +=
cur_time - stat->last_time;
stat->last_time = cur_time;
- mutex_unlock(&cpufreq_stats_lock);
return 0;
}
@@ -62,7 +60,10 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
ssize_t len = 0;
int i;
+ mutex_lock(&cpufreq_stats_lock);
cpufreq_stats_update(stat);
+ mutex_unlock(&cpufreq_stats_lock);
+
for (i = 0; i < stat->state_num; i++) {
len += sprintf(buf + len, "%u %llu\n", stat->freq_table[i],
(unsigned long long)
@@ -303,9 +304,9 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
if (old_index == new_index)
return 0;
+ mutex_lock(&cpufreq_stats_lock);
cpufreq_stats_update(stat);
- mutex_lock(&cpufreq_stats_lock);
stat->last_index = new_index;
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
stat->trans_table[old_index * stat->max_state + new_index]++;