mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM list <linux-pm@vger.kernel.org>,
	Doug Smythies <doug.smythies@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Ingo Molnar <mingo@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Morten Rasmussen <morten.rasmussen@arm.com>,
	Juri Lelli <Juri.Lelli@arm.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steve Muckle <smuckle@linaro.org>
Subject: [RFC/RFT][PATCH 3/4] cpufreq: intel_pstate: Use average P-state in get_target_pstate_default()
Date: Sat, 03 Sep 2016 03:03:35 +0200	[thread overview]
Message-ID: <4068903.sPRXPKuvpJ@vostro.rjw.lan> (raw)
In-Reply-To: <2730042.XLMy9dAKI1@vostro.rjw.lan>

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

Adjust the next P-state formula in get_target_pstate_default()
(in the filtered case) to use the average P-state as given by
the APERF and MPERF feedback registers instead of the exact
P-state requested previously, as that request might not be
granted.

Suggested-by: Doug Smythies <dsmythies@telus.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/intel_pstate.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/intel_pstate.c
+++ linux-pm/drivers/cpufreq/intel_pstate.c
@@ -98,7 +98,6 @@ static inline u64 div_ext_fp(u64 x, u64
  * @tsc:		Difference of time stamp counter between last and
  *			current sample
  * @time:		Current time from scheduler
- * @target:		Target P-state
  *
  * This structure is used in the cpudata structure to store performance sample
  * data for choosing next P State.
@@ -110,7 +109,6 @@ struct sample {
 	u64 mperf;
 	u64 tsc;
 	u64 time;
-	int target;
 };
 
 /**
@@ -1149,7 +1147,6 @@ static void intel_pstate_set_min_pstate(
 
 	trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu);
 	cpu->pstate.current_pstate = pstate;
-	cpu->sample.target = pstate;
 	/*
 	 * Generally, there is no guarantee that this code will always run on
 	 * the CPU being updated, so force the register update to run on the
@@ -1305,8 +1302,8 @@ static inline int32_t get_target_pstate_
 {
 	struct sample *sample = &cpu->sample;
 	int32_t busy_frac, boost;
-	int pstate, max_perf, min_perf;
 	int64_t target;
+	int pstate;
 
 	pstate = limits->no_turbo || limits->turbo_disabled ?
 			cpu->pstate.max_pstate : cpu->pstate.turbo_pstate;
@@ -1341,17 +1338,20 @@ static inline int32_t get_target_pstate_
 		 * Take the raw gain as 1/8 and compute the effective gain as
 		 *
 		 *	iir_gain = 1/8 * delta_t / sampling_interval
+		 *
+		 * Moreover, since the output is a request that may or may not
+		 * be granted (depending on what the other CPUs are doing, for
+		 * example), instead of using the output value obtained
+		 * previously in the computation, use the effective average
+		 * P-state since the last pass as given by APERF and MPERF.
 		 */
 		iir_gain = div_fp(sample->time - cpu->last_sample_time,
 				  pid_params.sample_rate_ns << 3);
 		if (iir_gain < int_tofp(1))
-			target = sample->target * (int_tofp(1) - iir_gain) +
+			target = get_avg_pstate(cpu) * (int_tofp(1) - iir_gain) +
 					mul_fp(target, iir_gain);
 	}
-	intel_pstate_get_min_max(cpu, &min_perf, &max_perf);
-	target = clamp_val(target, int_tofp(min_perf), int_tofp(max_perf));
-	sample->target = fp_toint(target + (1 << (FRAC_BITS-1)));
-	return sample->target;
+	return fp_toint(target + (1 << (FRAC_BITS-1)));
 }
 
 static inline void intel_pstate_update_pstate(struct cpudata *cpu, int pstate)

  parent reply	other threads:[~2016-09-03  0:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-03  0:56 [RFC/RFT][PATCH 0/4] cpufreq / sched: iowait boost in intel_pstate and schedutil Rafael J. Wysocki
2016-09-03  0:58 ` [RFC/RFT][PATCH 1/4] cpufreq / sched: SCHED_CPUFREQ_IOWAIT flag to indicate iowait condition Rafael J. Wysocki
2016-09-03  1:02 ` [RFC/RFT][PATCH 2/4] cpufreq: intel_pstate: Change P-state selection algorithm for Core Rafael J. Wysocki
2016-09-03  1:03 ` Rafael J. Wysocki [this message]
2016-09-03  1:04 ` [RFC/RFT][PATCH 4/4] cpufreq: schedutil: Add iowait boosting Rafael J. Wysocki
2016-09-07 15:26 ` [RFC/RFT][PATCH 2/4] cpufreq: intel_pstate: Change P-state selection algorithm for Core Doug Smythies
2016-09-08  0:22 ` [RFC/RFT][PATCH 0/4] cpufreq / sched: iowait boost in intel_pstate and schedutil Steve Muckle
2016-09-08  0:35   ` Srinivas Pandruvada
2016-09-08  0:44     ` Rafael J. Wysocki
2016-09-08  0:49       ` Srinivas Pandruvada
2016-09-08  1:15         ` Rafael J. Wysocki
2016-09-08 15:02           ` Rafael J. Wysocki
2016-09-08 17:30             ` Srinivas Pandruvada
2016-09-08 19:26     ` Steve Muckle
2016-09-08 19:49       ` Srinivas Pandruvada
2016-09-08  0:37   ` 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=4068903.sPRXPKuvpJ@vostro.rjw.lan \
    --to=rjw@rjwysocki.net \
    --cc=Juri.Lelli@arm.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=doug.smythies@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=morten.rasmussen@arm.com \
    --cc=peterz@infradead.org \
    --cc=smuckle@linaro.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=vincent.guittot@linaro.org \
    --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

all inboxes | Powered by JetHome®