Skip to content

Commit

Permalink
cpufreq: stats: don't update stats on false notifiers
Browse files Browse the repository at this point in the history
We need to call cpufreq_stats_update() to update 'time_in_state' for the last
frequency. This is achieved by calling it from cpufreq_stat_notifier_trans(),
which is called after frequency transition.

But if we detect that the cpu's frequency haven't really changed and its a false
POSTCHANGE notification, we don't really need to update time_in_state.

It wouldn't cause any harm in calling cpufreq_stats_update() but we can avoid
calling it here and call it when the frequency really changes. The result will
be the same but more efficient.

Reviewed-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Viresh Kumar authored and Rafael J. Wysocki committed Jan 23, 2015
1 parent 9225913 commit e734769
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/cpufreq/cpufreq_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ static int cpufreq_stat_notifier_trans(struct notifier_block *nb,
if (old_index == -1 || new_index == -1)
goto put_policy;

cpufreq_stats_update(stats);

if (old_index == new_index)
goto put_policy;

cpufreq_stats_update(stats);

spin_lock(&cpufreq_stats_lock);
stats->last_index = new_index;
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
Expand Down

0 comments on commit e734769

Please sign in to comment.