From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Christian Loehle <christian.loehle@arm.com>,
Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Subject: [PATCH v1 2/4] cpuidle: teo: Rearrange idle state lookup code
Date: Fri, 10 Jan 2025 13:54:39 +0100 [thread overview]
Message-ID: <3332506.aeNJFYEL58@rjwysocki.net> (raw)
In-Reply-To: <4953183.GXAFRqVoOG@rjwysocki.net>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Rearrange code in the idle state lookup loop in teo_select() to make it
somewhat easier to follow and update comments around it.
No intentional functional impact.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/cpuidle/governors/teo.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -367,7 +367,7 @@
* If the sum of the intercepts metric for all of the idle states
* shallower than the current candidate one (idx) is greater than the
* sum of the intercepts and hits metrics for the candidate state and
- * all of the deeper states a shallower idle state is likely to be a
+ * all of the deeper states, a shallower idle state is likely to be a
* better choice.
*/
prev_intercept_idx = idx;
@@ -396,30 +396,36 @@
* first enabled state that is deep enough.
*/
if (teo_state_ok(i, drv) &&
- !dev->states_usage[i].disable)
+ !dev->states_usage[i].disable) {
idx = i;
- else
- idx = first_suitable_idx;
-
+ break;
+ }
+ idx = first_suitable_idx;
break;
}
if (dev->states_usage[i].disable)
continue;
- if (!teo_state_ok(i, drv)) {
+ if (teo_state_ok(i, drv)) {
/*
- * The current state is too shallow, but if an
- * alternative candidate state has been found,
- * it may still turn out to be a better choice.
+ * The current state is deep enough, but still
+ * there may be a better one.
*/
- if (first_suitable_idx != idx)
- continue;
-
- break;
+ first_suitable_idx = i;
+ continue;
}
- first_suitable_idx = i;
+ /*
+ * The current state is too shallow, so if no suitable
+ * states other than the initial candidate have been
+ * found, give up (the remaining states to check are
+ * shallower still), but otherwise the first suitable
+ * state other than the initial candidate may turn out
+ * to be preferable.
+ */
+ if (first_suitable_idx == idx)
+ break;
}
}
if (!idx && prev_intercept_idx &&
next prev parent reply other threads:[~2025-01-10 12:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-10 12:51 [PATCH v1 0/4] cpuidle: teo: Fix and cleanups Rafael J. Wysocki
2025-01-10 12:53 ` [PATCH v1 1/4] cpuidle: teo: Add polling flag check to early return path Rafael J. Wysocki
2025-01-10 13:16 ` Christian Loehle
2025-01-10 13:34 ` Rafael J. Wysocki
2025-01-10 14:52 ` Christian Loehle
2025-01-10 15:17 ` Rafael J. Wysocki
2025-01-10 17:23 ` Rafael J. Wysocki
2025-01-23 16:54 ` Artem Bityutskiy
2025-01-23 18:12 ` Rafael J. Wysocki
2025-01-10 12:54 ` Rafael J. Wysocki [this message]
2025-01-10 12:55 ` [PATCH v1 3/4] cpuidle: teo: Reorder candidate state index checks Rafael J. Wysocki
2025-01-10 12:56 ` [PATCH v1 4/4] cpuidle: teo: Combine candidate state index checks against 0 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=3332506.aeNJFYEL58@rjwysocki.net \
--to=rjw@rjwysocki.net \
--cc=artem.bityutskiy@linux.intel.com \
--cc=christian.loehle@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
/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