Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: stats: don't update stats on false notifiers

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>

authored by

Viresh Kumar and committed by
Rafael J. Wysocki
e7347694 9225913d

+2 -2
+2 -2
drivers/cpufreq/cpufreq_stats.c
··· 289 289 if (old_index == -1 || new_index == -1) 290 290 goto put_policy; 291 291 292 - cpufreq_stats_update(stats); 293 - 294 292 if (old_index == new_index) 295 293 goto put_policy; 294 + 295 + cpufreq_stats_update(stats); 296 296 297 297 spin_lock(&cpufreq_stats_lock); 298 298 stats->last_index = new_index;