public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: anna-maria@linutronix.de, rafael@kernel.org, tglx@linutronix.de,
	frederic@kernel.org, gautham.shenoy@amd.com
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
	daniel.lezcano@linaro.org, linux-pm@vger.kernel.org,
	mingo@redhat.com, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, vschneid@redhat.com,
	kajetan.puchalski@arm.com
Subject: [RFC][PATCH v2 5/5] cpuidle,teo: Improve state selection
Date: Wed, 02 Aug 2023 15:24:36 +0200	[thread overview]
Message-ID: <20230802132925.824393002@infradead.org> (raw)
In-Reply-To: 20230802132431.254614419@infradead.org

When selecting a state, stop when history tells us 66% of recent idles
were at or below our current state.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 drivers/cpuidle/governors/teo.c |    6 ++++++
 1 file changed, 6 insertions(+)

--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -361,6 +361,7 @@ static int teo_select(struct cpuidle_dri
 	unsigned int recent_sum = 0;
 	unsigned int idx_hit_sum = 0;
 	unsigned int hit_sum = 0;
+	unsigned int thresh_sum = 0;
 	int constraint_idx = 0;
 	int idx0 = 0, idx = -1;
 	bool alt_intercepts, alt_recent;
@@ -376,6 +377,8 @@ static int teo_select(struct cpuidle_dri
 
 	duration_ns = tick_ns = tick_get_sleep_length(false);
 
+	thresh_sum = 2 * cpu_data->total / 3; /* 66% */
+
 	/*
 	 * Find the deepest idle state whose target residency does not exceed
 	 * the current sleep length and the deepest idle state not deeper than
@@ -406,6 +409,9 @@ static int teo_select(struct cpuidle_dri
 		if (s->target_residency_ns > duration_ns)
 			break;
 
+		if (intercept_sum + hit_sum > thresh_sum)
+			break;
+
 		if (s->target_residency_ns == SHORT_TICK_NSEC) {
 			/*
 			 * We hit the tick state, see if it makes sense to



      parent reply	other threads:[~2023-08-02 13:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-02 13:24 [RFC][PATCH v2 0/5] cpuidle,teo: Improve TEO vs NOHZ Peter Zijlstra
2023-08-02 13:24 ` [RFC][PATCH v2 1/5] tick/nohz: Introduce tick_get_sleep_length() Peter Zijlstra
2023-08-02 13:24 ` [RFC][PATCH v2 2/5] cpuidle: Inject tick boundary state Peter Zijlstra
2023-08-02 13:24 ` [RFC][PATCH v2 3/5] cpuidle/teo: Simplify a little Peter Zijlstra
2023-08-03 10:12   ` Kajetan Puchalski
2023-08-02 13:24 ` [RFC][PATCH v2 4/5] cpuidle/teo: Avoid tick_nohz_next_event() Peter Zijlstra
2023-08-02 13:24 ` Peter Zijlstra [this message]

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=20230802132925.824393002@infradead.org \
    --to=peterz@infradead.org \
    --cc=anna-maria@linutronix.de \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=frederic@kernel.org \
    --cc=gautham.shenoy@amd.com \
    --cc=juri.lelli@redhat.com \
    --cc=kajetan.puchalski@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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