linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Zhang Rui <rui.zhang@intel.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] cpufreq: Introduce target min and max frequency hints
Date: Thu, 05 Nov 2020 19:23:34 +0100	[thread overview]
Message-ID: <2233690.N3OVLkotou@kreacher> (raw)
In-Reply-To: <7417968.Ghue05m4RV@kreacher>

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

Some cpufreq drivers, like intel_pstate (in the passive mode with
HWP enabled) or the CPPC driver, take the "target frequency" coming
from the governor as a hint to pass to the hardware rather than the
exact value to apply.  Then, the hardware may choose to run at
whatever performance point it regards as appropriate, given the
hint and some other data available to it.

Of course, the performance point chosen by the hardware should
stay within the policy min and max limits, but in some cases it may
be necessary to request the hardware to limit the range of
performance points to consider beyond that.

For example, if the powersave governor is in use, it attempts to
make the hardware run at the policy min frequency, but that may
not actually work if the hardware thinks that it has a reason to
run faster and the policy max limit is above the policy min.

In those cases, it is useful to pass additional information to the
driver to indicate that it should tell the hardware to consider a
narrower range of performance points, so add two new fields,
target_min and target_max, to struct cpufreq_policy for this purpose
and make the powersave and performance governors set them to indicate
that the CPU is expected to run exactly at the given frequency (the
policy min or max, respectively).

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/cpufreq.c             |    3 +++
 drivers/cpufreq/cpufreq_performance.c |    4 ++++
 drivers/cpufreq/cpufreq_powersave.c   |    4 ++++
 include/linux/cpufreq.h               |   16 ++++++++++++++++
 4 files changed, 27 insertions(+)

Index: linux-pm/include/linux/cpufreq.h
===================================================================
--- linux-pm.orig/include/linux/cpufreq.h
+++ linux-pm/include/linux/cpufreq.h
@@ -63,6 +63,8 @@ struct cpufreq_policy {
 
 	unsigned int		min;    /* in kHz */
 	unsigned int		max;    /* in kHz */
+	unsigned int		target_min; /* in kHz */
+	unsigned int		target_max; /* in kHz */
 	unsigned int		cur;    /* in kHz, only needed if cpufreq
 					 * governors are used */
 	unsigned int		suspend_freq; /* freq to set during suspend */
Index: linux-pm/drivers/cpufreq/cpufreq.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq.c
+++ linux-pm/drivers/cpufreq/cpufreq.c
@@ -2272,6 +2272,9 @@ static int cpufreq_init_governor(struct
 
 	pr_debug("%s: for CPU %u\n", __func__, policy->cpu);
 
+	policy->target_min = policy->cpuinfo.min_freq;
+	policy->target_max = policy->cpuinfo.max_freq;
+
 	if (policy->governor->init) {
 		ret = policy->governor->init(policy);
 		if (ret) {
Index: linux-pm/drivers/cpufreq/cpufreq_performance.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq_performance.c
+++ linux-pm/drivers/cpufreq/cpufreq_performance.c
@@ -14,6 +14,10 @@
 static void cpufreq_gov_performance_limits(struct cpufreq_policy *policy)
 {
 	pr_debug("setting to %u kHz\n", policy->max);
+
+	policy->target_min = policy->max;
+	policy->target_max = policy->max;
+
 	__cpufreq_driver_target(policy, policy->max, CPUFREQ_RELATION_H);
 }
 
Index: linux-pm/drivers/cpufreq/cpufreq_powersave.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/cpufreq_powersave.c
+++ linux-pm/drivers/cpufreq/cpufreq_powersave.c
@@ -14,6 +14,10 @@
 static void cpufreq_gov_powersave_limits(struct cpufreq_policy *policy)
 {
 	pr_debug("setting to %u kHz\n", policy->min);
+
+	policy->target_min = policy->min;
+	policy->target_max = policy->min;
+
 	__cpufreq_driver_target(policy, policy->min, CPUFREQ_RELATION_L);
 }
 




  reply	other threads:[~2020-11-05 18:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 18:17 [PATCH 0/2] cpufreq: intel_pstate: Handle powersave governor correctly in the passive mode with HWP Rafael J. Wysocki
2020-11-05 18:23 ` Rafael J. Wysocki [this message]
2020-11-06  1:49   ` [PATCH 1/2] cpufreq: Introduce target min and max frequency hints Doug Smythies
2020-11-06 10:07   ` Viresh Kumar
2020-11-06 17:02     ` Rafael J. Wysocki
2020-11-09  4:39       ` Viresh Kumar
2020-11-09 12:27         ` Rafael J. Wysocki
2020-11-05 18:25 ` [PATCH 2/2] cpufreq: intel_pstate: Take target_min and target_max into account 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=2233690.N3OVLkotou@kreacher \
    --to=rjw@rjwysocki.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=viresh.kumar@linaro.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;
as well as URLs for NNTP newsgroup(s).