linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kajetan Puchalski <kajetan.puchalski@arm.com>
To: rafael@kernel.org
Cc: daniel.lezcano@linaro.org, lukasz.luba@arm.com,
	Dietmar.Eggemann@arm.com, dsmythies@telus.net,
	yu.chen.surf@gmail.com, kajetan.puchalski@arm.com,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v3 1/2] cpuidle: teo: Optionally skip polling states in teo_find_shallower_state()
Date: Mon, 31 Oct 2022 12:13:13 +0000	[thread overview]
Message-ID: <20221031121314.1381472-2-kajetan.puchalski@arm.com> (raw)
In-Reply-To: <20221031121314.1381472-1-kajetan.puchalski@arm.com>

Add a no_poll flag to teo_find_shallower_state() that will let the
function optionally not consider polling states.
This allows the caller to guard against the function inadvertently
resulting in TEO putting the CPU in a polling state when that
behaviour is undesirable.

Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
---
 drivers/cpuidle/governors/teo.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index d9262db79cae..e2864474a98d 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -258,15 +258,17 @@ static s64 teo_middle_of_bin(int idx, struct cpuidle_driver *drv)
  * @dev: Target CPU.
  * @state_idx: Index of the capping idle state.
  * @duration_ns: Idle duration value to match.
+ * @no_poll: Don't consider polling states.
  */
 static int teo_find_shallower_state(struct cpuidle_driver *drv,
 				    struct cpuidle_device *dev, int state_idx,
-				    s64 duration_ns)
+				    s64 duration_ns, bool no_poll)
 {
 	int i;
 
 	for (i = state_idx - 1; i >= 0; i--) {
-		if (dev->states_usage[i].disable)
+		if (dev->states_usage[i].disable ||
+				(no_poll && drv->states[i].flags & CPUIDLE_FLAG_POLLING))
 			continue;
 
 		state_idx = i;
@@ -469,7 +471,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
 		 */
 		if (idx > idx0 &&
 		    drv->states[idx].target_residency_ns > delta_tick)
-			idx = teo_find_shallower_state(drv, dev, idx, delta_tick);
+			idx = teo_find_shallower_state(drv, dev, idx, delta_tick, false);
 	}
 
 	return idx;
-- 
2.37.1


  reply	other threads:[~2022-10-31 12:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 12:13 [RFC PATCH v3 0/2] cpuidle: teo: Introduce util-awareness Kajetan Puchalski
2022-10-31 12:13 ` Kajetan Puchalski [this message]
2022-10-31 12:13 ` [RFC PATCH v3 2/2] " Kajetan Puchalski
2022-11-01  6:24   ` Doug Smythies
2022-11-01 23:02     ` Doug Smythies
2022-11-02 14:01     ` Kajetan Puchalski
2022-11-25 18:27   ` Rafael J. Wysocki
2022-11-25 20:00     ` Doug Smythies
2022-11-27  4:29     ` Doug Smythies
2022-11-28 14:32     ` Kajetan Puchalski
2022-11-28 14:54       ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221031121314.1381472-2-kajetan.puchalski@arm.com \
    --to=kajetan.puchalski@arm.com \
    --cc=Dietmar.Eggemann@arm.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=dsmythies@telus.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=rafael@kernel.org \
    --cc=yu.chen.surf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).