linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cros_ec_spi: Even though we're RT priority, don't bump cpu freq
@ 2020-06-10 22:18 Douglas Anderson
  2020-06-11 11:03 ` Quentin Perret
  2020-06-12 12:52 ` Qais Yousef
  0 siblings, 2 replies; 26+ messages in thread
From: Douglas Anderson @ 2020-06-10 22:18 UTC (permalink / raw)
  To: Benson Leung, Enric Balletbo i Serra
  Cc: hsinyi, joelaf, peterz, drinkcat, gwendal, qperret, ctheegal,
	Douglas Anderson, Guenter Roeck, linux-kernel

The cros_ec_spi driver is realtime priority so that it doesn't get
preempted by other taks while it's talking to the EC but overall it
really doesn't need lots of compute power.  Unfortunately, by default,
the kernel assumes that all realtime tasks should cause the cpufreq to
jump to max and burn through power to get things done as quickly as
possible.  That's just not the correct behavior for cros_ec_spi.

Switch to manually overriding the default.

This won't help us if our work moves over to the SPI pump thread but
that's not the common code path.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
---
NOTE: This would cause a conflict if the patch
https://lore.kernel.org/r/20200422112831.870192415@infradead.org lands
first

 drivers/platform/chrome/cros_ec_spi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_spi.c b/drivers/platform/chrome/cros_ec_spi.c
index debea5c4c829..76d59d5e7efd 100644
--- a/drivers/platform/chrome/cros_ec_spi.c
+++ b/drivers/platform/chrome/cros_ec_spi.c
@@ -709,8 +709,11 @@ static void cros_ec_spi_high_pri_release(void *worker)
 static int cros_ec_spi_devm_high_pri_alloc(struct device *dev,
 					   struct cros_ec_spi *ec_spi)
 {
-	struct sched_param sched_priority = {
-		.sched_priority = MAX_RT_PRIO / 2,
+	struct sched_attr sched_attr = {
+		.sched_policy	= SCHED_FIFO,
+		.sched_priority	= MAX_RT_PRIO / 2,
+		.sched_flags	= SCHED_FLAG_UTIL_CLAMP_MIN,
+		.sched_util_min	= 0,
 	};
 	int err;
 
@@ -728,8 +731,7 @@ static int cros_ec_spi_devm_high_pri_alloc(struct device *dev,
 	if (err)
 		return err;
 
-	err = sched_setscheduler_nocheck(ec_spi->high_pri_worker->task,
-					 SCHED_FIFO, &sched_priority);
+	err = sched_setattr_nocheck(ec_spi->high_pri_worker->task, &sched_attr);
 	if (err)
 		dev_err(dev, "Can't set cros_ec high pri priority: %d\n", err);
 	return err;
-- 
2.27.0.290.gba653c62da-goog


^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-06-25 14:20 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 22:18 [PATCH] cros_ec_spi: Even though we're RT priority, don't bump cpu freq Douglas Anderson
2020-06-11 11:03 ` Quentin Perret
2020-06-11 17:48   ` Doug Anderson
2020-06-12  9:24     ` Quentin Perret
2020-06-12 12:34       ` Qais Yousef
2020-06-12 13:47         ` Quentin Perret
2020-06-12 14:00           ` Qais Yousef
2020-06-18 21:31         ` Doug Anderson
2020-06-19 15:31           ` Qais Yousef
2020-06-22 18:19             ` Doug Anderson
2020-06-23 15:56               ` Qais Yousef
2020-06-12 12:52 ` Qais Yousef
2020-06-18 21:18   ` Doug Anderson
2020-06-19 15:38     ` Qais Yousef
2020-06-22 18:21       ` Doug Anderson
2020-06-23 16:40         ` Qais Yousef
2020-06-24 15:49           ` Joel Fernandes
2020-06-24 16:55             ` Qais Yousef
2020-06-24 17:35               ` Joel Fernandes
2020-06-24 17:52                 ` Qais Yousef
2020-06-24 17:55                   ` Joel Fernandes
2020-06-24 18:29                     ` Doug Anderson
2020-06-25 14:20                       ` Qais Yousef
2020-06-24 16:01           ` Peter Zijlstra
2020-06-24 17:14             ` Qais Yousef
2020-06-24 15:56     ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).