diff mbox series

[RFC,7/7] thermal/cpu-cooling: Update thermal pressure in case of a maximum frequency capping

Message ID 1539102302-9057-8-git-send-email-thara.gopinath@linaro.org
State New
Headers show
Series Introduce thermal pressure | expand

Commit Message

Thara Gopinath Oct. 9, 2018, 4:25 p.m. UTC
Thermal governors can request for a cpu's maximum supported frequency
to be capped in case of an overheat event. This in turn means that the
maximum capacity available for tasks to run on the particular cpu is
reduced. Delta between the original maximum capacity and capped
maximum capacity is known as thermal pressure. Enable cpufreq cooling
device to update the thermal pressure in event of a capped
maximum frequency.

Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>

---
 drivers/thermal/cpu_cooling.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

-- 
2.1.4
diff mbox series

Patch

diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c
index dfd2324..da8de66 100644
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -31,6 +31,7 @@ 
 #include <linux/slab.h>
 #include <linux/cpu.h>
 #include <linux/cpu_cooling.h>
+#include <linux/sched/topology.h>
 
 #include <trace/events/thermal.h>
 
@@ -132,6 +133,21 @@  static unsigned long get_level(struct cpufreq_cooling_device *cpufreq_cdev,
 }
 
 /**
+ * cpufreq_update_sched_max_capacity - update scheduler about change in cpu
+ *					max frequency.
+ * @policy - cpufreq policy whose max frequency is capped.
+ */
+static void cpufreq_update_sched_max_capacity(struct cpufreq_policy *policy)
+{
+	int cpu;
+	unsigned long capacity = (policy->max << SCHED_CAPACITY_SHIFT) /
+					policy->cpuinfo.max_freq;
+
+	for_each_cpu(cpu, policy->cpus)
+		update_maxcap_capacity(cpu, capacity);
+}
+
+/**
  * cpufreq_thermal_notifier - notifier callback for cpufreq policy change.
  * @nb:	struct notifier_block * with callback info.
  * @event: value showing cpufreq event for which this function invoked.
@@ -175,8 +191,10 @@  static int cpufreq_thermal_notifier(struct notifier_block *nb,
 		 */
 		clipped_freq = cpufreq_cdev->clipped_freq;
 
-		if (policy->max > clipped_freq)
+		if (policy->max > clipped_freq) {
 			cpufreq_verify_within_limits(policy, 0, clipped_freq);
+			cpufreq_update_sched_max_capacity(policy);
+		}
 		break;
 	}
 	mutex_unlock(&cooling_list_lock);