cpufreq: Manage governor usage history with 'policy->last_governor'
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 12 May 2015 06:52:34 +0000 (12:22 +0530)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 15 May 2015 00:44:17 +0000 (02:44 +0200)
commit4573237b01221881702fbe6655f3ae5135be1c18
treef4923a1b61a7c7fb7a407bc067ea98a835a5cd16
parent9104bb26c740cd4b2c9ee927f3caabbde0414558
cpufreq: Manage governor usage history with 'policy->last_governor'

History of which governor was used last is common to all CPUs within a
policy and maintaining it per-cpu isn't the best approach for sure.

Apart from wasting memory, this also increases the complexity of
managing this data structure as it has to be updated for all CPUs.

To make that somewhat simpler, lets store this information in a new
field 'last_governor' in struct cpufreq_policy and update it on removal
of last cpu of a policy.

As a side-effect it also solves an old problem, consider a system with
two clusters 0 & 1. And there is one policy per cluster.

Cluster 0: CPU0 and 1.
Cluster 1: CPU2 and 3.

 - CPU2 is first brought online, and governor is set to performance
   (default as cpufreq_cpu_governor wasn't set).
 - Governor is changed to ondemand.
 - CPU2 is taken offline and cpufreq_cpu_governor is updated for CPU2.
 - CPU3 is brought online.
 - Because cpufreq_cpu_governor wasn't set for CPU3, the default governor
   performance is picked for CPU3.

This patch fixes the bug as we now have a single variable to update for
policy.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/cpufreq/cpufreq.c
include/linux/cpufreq.h