All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal/drivers/cpuidle_cooling: Make sure that idle_duration is larger than residency
@ 2021-04-02  4:56 zhuguangqing83
  0 siblings, 0 replies; only message in thread
From: zhuguangqing83 @ 2021-04-02  4:56 UTC (permalink / raw)
  To: Amit Daniel Kachhap, Daniel Lezcano, Viresh Kumar, Javi Merino,
	Zhang Rui, Amit Kucheria, Rafael J . Wysocki
  Cc: linux-pm, linux-kernel, Guangqing Zhu

From: Guangqing Zhu <zhuguangqing83@gmail.com>

The injected idle duration should be greater than the idle state min
residency, otherwise we end up consuming more energy and potentially invert
the mitigation effect.

In function __cpuidle_cooling_register(), if
of_property_read_u32(np, "exit-latency-us", &latency_us) is failed, then
maybe we should not use latency_us. In this case, a zero latency_us for
forced_idle_latency_limit_ns is better than UMAX_INT. It means to use
governors in the usual way.

Signed-off-by: Guangqing Zhu <zhuguangqing83@gmail.com>
---
 drivers/powercap/idle_inject.c    | 1 -
 drivers/thermal/cpuidle_cooling.c | 8 +++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/powercap/idle_inject.c b/drivers/powercap/idle_inject.c
index 6e1a0043c411..d76eef1e9387 100644
--- a/drivers/powercap/idle_inject.c
+++ b/drivers/powercap/idle_inject.c
@@ -309,7 +309,6 @@ struct idle_inject_device *idle_inject_register(struct cpumask *cpumask)
 	cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask);
 	hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	ii_dev->timer.function = idle_inject_timer_fn;
-	ii_dev->latency_us = UINT_MAX;
 
 	for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) {
 
diff --git a/drivers/thermal/cpuidle_cooling.c b/drivers/thermal/cpuidle_cooling.c
index 7ecab4b16b29..de770eb5b2ba 100644
--- a/drivers/thermal/cpuidle_cooling.c
+++ b/drivers/thermal/cpuidle_cooling.c
@@ -175,7 +175,8 @@ static int __cpuidle_cooling_register(struct device_node *np,
 	struct cpuidle_cooling_device *idle_cdev;
 	struct thermal_cooling_device *cdev;
 	unsigned int idle_duration_us = TICK_USEC;
-	unsigned int latency_us = UINT_MAX;
+	unsigned int latency_us = 0;
+	unsigned int residency_us = UINT_MAX;
 	char dev_name[THERMAL_NAME_LENGTH];
 	int id, ret;
 
@@ -199,6 +200,11 @@ static int __cpuidle_cooling_register(struct device_node *np,
 
 	of_property_read_u32(np, "duration-us", &idle_duration_us);
 	of_property_read_u32(np, "exit-latency-us", &latency_us);
+	of_property_read_u32(np, "min-residency-us", &residency_us);
+	if (idle_duration_us <= residency_us) {
+		ret = -EINVAL;
+		goto out_unregister;
+	}
 
 	idle_inject_set_duration(ii_dev, TICK_USEC, idle_duration_us);
 	idle_inject_set_latency(ii_dev, latency_us);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-02  4:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-02  4:56 [PATCH] thermal/drivers/cpuidle_cooling: Make sure that idle_duration is larger than residency zhuguangqing83

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.