linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: rjw@rjwysocki.net
Cc: nicolas.pitre@linaro.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, peterz@infradead.org,
	linaro-kernel@lists.linaro.org, patches@linaro.org
Subject: [PATCH V2 4/5] cpuidle: menu: Fix the get_typical_interval
Date: Thu, 23 Oct 2014 11:01:20 +0200	[thread overview]
Message-ID: <1414054881-17713-4-git-send-email-daniel.lezcano@linaro.org> (raw)
In-Reply-To: <1414054881-17713-1-git-send-email-daniel.lezcano@linaro.org>

The first time the 'get_typical_function' is called, it computes an average
of zero as no data is filled yet. That leads the 'data->predicted_us' variable
to be set to zero too.

The caller, 'menu_select' will then do:

	interactivity_req = data->predicted_us /
			performance_multiplier(nr_iowaiters, cpu_load);

That sets the interactivity_req to zero (0/performance...).

and then

	if (latency_req > interactivity_req)
		latency_req = interactivity_req;

... setting 'latency_req' to zero too.

No idle state will fulfill this constraint and we will go the C1 state as
default and leading to an update. So the next calls will compute an average
different from zero.

Even if that works with the current code but with a broken semantic, it will
just break with the next patches where we are stricter with the latencies
check: the first check will fail (latency_req is zero), then no update will
occur leading to always falling to choose an idle state.

As there are no previous values and it is pointless to compute a standard
deviation for these unexisting values. Just return without setting the
'data->predicted_us' to zero.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpuidle/governors/menu.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 3907301..6ae8390 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -226,6 +226,15 @@ again:
 	else
 		do_div(avg, divisor);
 
+	/*
+	 * We are at the very beginning and no data have been filled
+	 * yet. Let's skip the standard deviation computation
+	 * otherwise the data->predicted_us will be zero and that will
+	 * lead to a zero latency req in the select function
+	 */
+	if (!avg)
+		return;
+
 	/* Then try to determine standard deviation */
 	stddev = 0;
 	for (i = 0; i < INTERVALS; i++) {
-- 
1.9.1

  parent reply	other threads:[~2014-10-23  9:01 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23  9:01 [PATCH V2 1/5] sched: idle: cpuidle: Check the latency req before idle Daniel Lezcano
2014-10-23  9:01 ` [PATCH V2 2/5] sched: idle: Get the next timer event and pass it the cpuidle framework Daniel Lezcano
2014-10-23  9:01 ` [PATCH V2 3/5] cpuidle: idle: menu: Don't reflect when a state selection failed Daniel Lezcano
2014-10-28  2:01   ` Len Brown
2014-10-28 19:15     ` Daniel Lezcano
2014-10-28  7:01   ` Preeti Murthy
2014-10-28 18:28     ` Daniel Lezcano
2014-10-29  1:44       ` Preeti U Murthy
2014-10-29 16:54       ` Kevin Hilman
2014-10-29 21:11         ` Rafael J. Wysocki
2014-10-23  9:01 ` Daniel Lezcano [this message]
2014-10-23 16:43   ` [PATCH V2 4/5] cpuidle: menu: Fix the get_typical_interval Nicolas Pitre
2014-10-28  2:48   ` Len Brown
2014-10-29 18:15     ` Daniel Lezcano
2014-10-23  9:01 ` [PATCH V2 5/5] cpuidle: menu: Move the update function before its declaration Daniel Lezcano
2014-10-23 16:47   ` Nicolas Pitre
2014-10-28  2:53     ` Len Brown
2014-10-28  3:51 ` [PATCH V2 1/5] sched: idle: cpuidle: Check the latency req before idle Preeti Murthy
2014-10-28 18:59   ` Daniel Lezcano
2014-10-29  2:01     ` Preeti U Murthy
2014-11-05 14:28       ` Daniel Lezcano
2014-11-06  4:08         ` Preeti U Murthy
2014-11-06 12:27           ` Daniel Lezcano
2014-11-07  4:23             ` Preeti U Murthy
2014-11-06 13:42           ` Daniel Lezcano
2014-11-07  4:29             ` Preeti U Murthy
2014-11-07  9:35               ` Daniel Lezcano
2014-11-05 21:57 ` Rafael J. Wysocki
2014-11-05 21:41   ` Daniel Lezcano

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=1414054881-17713-4-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nicolas.pitre@linaro.org \
    --cc=patches@linaro.org \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    /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).