public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@gmail.com>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Waldemar Rymarkiewicz <waldemarx.rymarkiewicz@intel.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	t.bartholomae@intel.com
Subject: [PATCH] cpufreq: conservative: Take limits changes into account properly
Date: Mon, 15 Oct 2018 23:21:05 +0200	[thread overview]
Message-ID: <5406371.vuaACy5i7F@aspire.rjw.lan> (raw)
In-Reply-To: <CAJZ5v0gFjBoFi=cpC2gPkZTDZof8dxdCCVx0XoAv2XuPmTfWPA@mail.gmail.com>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

If the policy limits change between invocations of cs_dbs_update(),
the requested frequency value stored in dbs_info may not be updated
and the function may use a stale value of it next time.  Moreover, if
idle periods are takem into account by cs_dbs_update(), the requested
frequency value stored in dbs_info may be below the min policy limit,
which is incorrect.

To fix these problems, always update the requested frequency value
in dbs_info along with the local copy of it when the previous
requested frequency is beyond the policy limits and avoid decreasing
the requested frequency below the min policy limit when taking
idle periods into account.

Reported-by: Waldemar Rymarkiewicz <waldemarx.rymarkiewicz@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq_conservative.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: linux-pm/drivers/cpufreq/cpufreq_conservative.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq_conservative.c
+++ linux-pm/drivers/cpufreq/cpufreq_conservative.c
@@ -80,8 +80,10 @@ static unsigned int cs_dbs_update(struct
 	 * changed in the meantime, so fall back to current frequency in that
 	 * case.
 	 */
-	if (requested_freq > policy->max || requested_freq < policy->min)
+	if (requested_freq > policy->max || requested_freq < policy->min) {
 		requested_freq = policy->cur;
+		dbs_info->requested_freq = requested_freq;
+	}
 
 	freq_step = get_freq_step(cs_tuners, policy);
 
@@ -92,7 +94,7 @@ static unsigned int cs_dbs_update(struct
 	if (policy_dbs->idle_periods < UINT_MAX) {
 		unsigned int freq_steps = policy_dbs->idle_periods * freq_step;
 
-		if (requested_freq > freq_steps)
+		if (requested_freq > policy->min + freq_steps)
 			requested_freq -= freq_steps;
 		else
 			requested_freq = policy->min;

  reply	other threads:[~2018-10-15 21:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-08 15:09 [PATCH] cpufreq: conservative: Fix requested_freq handling Waldemar Rymarkiewicz
2018-10-09  7:47 ` Rafael J. Wysocki
2018-10-09 16:06   ` Waldemar Rymarkiewicz
2018-10-11 21:06     ` Rafael J. Wysocki
2018-10-15  9:34       ` Waldemar Rymarkiewicz
2018-10-15 11:31         ` Rafael J. Wysocki
2018-10-15 12:50           ` Waldemar Rymarkiewicz
2018-10-15 21:03             ` Rafael J. Wysocki
2018-10-15 21:21               ` Rafael J. Wysocki [this message]
2018-10-16  6:38                 ` [PATCH] cpufreq: conservative: Take limits changes into account properly Waldemar Rymarkiewicz
2018-10-16  9:52                 ` Viresh Kumar

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=5406371.vuaACy5i7F@aspire.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=t.bartholomae@intel.com \
    --cc=viresh.kumar@linaro.org \
    --cc=waldemar.rymarkiewicz@gmail.com \
    --cc=waldemarx.rymarkiewicz@intel.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