From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: srinivas.pandruvada@linux.intel.com, tglx@linutronix.de,
mingo@redhat.com, peterz@infradead.org, bp@suse.de,
lenb@kernel.org, rjw@rjwysocki.net, mgorman@techsingularity.net
Cc: x86@kernel.org, linux-pm@vger.kernel.org,
viresh.kumar@linaro.org, juri.lelli@arm.com,
linux-kernel@vger.kernel.org
Subject: [RFC/RFT] [PATCH 05/10] cpufreq: intel_pstate: HWP boost performance on IO Wake
Date: Tue, 15 May 2018 21:49:06 -0700 [thread overview]
Message-ID: <20180516044911.28797-6-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <20180516044911.28797-1-srinivas.pandruvada@linux.intel.com>
When a task is woken up from IO wait, boost HWP prformance to max. This
helps IO workloads on servers with per core P-states. But changing limits
has extra over head of issuing new HWP Request MSR, which takes 1000+
cycles. So this change limits setting HWP Request MSR. Also request can
be for a remote CPU.
Rate control in setting HWP Requests:
- If the current performance is around P1, simply ignore IO flag.
- Once set wait till hold time, till remove boost. While the boost
is on, another IO flags is notified, it will prolong boost.
- If the IO flags are notified multiple ticks apart, this may not be
IO bound task. Othewise idle system gets periodic boosts for one
IO wake.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/intel_pstate.c | 75 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index e200887..d418265 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -20,6 +20,7 @@
#include <linux/tick.h>
#include <linux/slab.h>
#include <linux/sched/cpufreq.h>
+#include <linux/sched/topology.h>
#include <linux/list.h>
#include <linux/cpu.h>
#include <linux/cpufreq.h>
@@ -224,6 +225,8 @@ struct global_params {
* @hwp_req_cached: Cached value of the last HWP request MSR
* @csd: A structure used to issue SMP async call, which
* defines callback and arguments
+ * @hwp_boost_active: HWP performance is boosted on this CPU
+ * @last_io_update: Last time when IO wake flag was set
*
* This structure stores per CPU instance data for all CPUs.
*/
@@ -258,6 +261,8 @@ struct cpudata {
s16 epp_saved;
u64 hwp_req_cached;
call_single_data_t csd;
+ bool hwp_boost_active;
+ u64 last_io_update;
};
static struct cpudata **all_cpu_data;
@@ -1421,10 +1426,80 @@ static void csd_init(struct cpudata *cpu)
cpu->csd.info = cpu;
}
+/*
+ * Long hold time will keep high perf limits for long time,
+ * which negatively impacts perf/watt for some workloads,
+ * like specpower. 3ms is based on experiements on some
+ * workoads.
+ */
+static int hwp_boost_hold_time_ms = 3;
+
+/* Default: This will roughly around P1 on SKX */
+#define BOOST_PSTATE_THRESHOLD (SCHED_CAPACITY_SCALE / 2)
+static int hwp_boost_pstate_threshold = BOOST_PSTATE_THRESHOLD;
+
+static inline bool intel_pstate_check_boost_threhold(struct cpudata *cpu)
+{
+ /*
+ * If the last performance is above threshold, then return false,
+ * so that caller can ignore boosting.
+ */
+ if (arch_scale_freq_capacity(cpu->cpu) > hwp_boost_pstate_threshold)
+ return false;
+
+ return true;
+}
+
static inline void intel_pstate_update_util_hwp(struct update_util_data *data,
u64 time, unsigned int flags)
{
+ struct cpudata *cpu = container_of(data, struct cpudata, update_util);
+
+ if (flags & SCHED_CPUFREQ_IOWAIT) {
+ /*
+ * Set iowait_boost flag and update time. Since IO WAIT flag
+ * is set all the time, we can't just conclude that there is
+ * some IO bound activity is scheduled on this CPU with just
+ * one occurrence. If we receive at least two in two
+ * consecutive ticks, then we start treating as IO. So
+ * there will be one tick latency.
+ */
+ if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC) &&
+ intel_pstate_check_boost_threhold(cpu))
+ cpu->iowait_boost = true;
+
+ cpu->last_io_update = time;
+ cpu->last_update = time;
+ }
+ /*
+ * If the boost is active, we will remove it after timeout on local
+ * CPU only.
+ */
+ if (cpu->hwp_boost_active) {
+ if (smp_processor_id() == cpu->cpu) {
+ bool expired;
+
+ expired = time_after64(time, cpu->last_update +
+ (hwp_boost_hold_time_ms * NSEC_PER_MSEC));
+ if (expired) {
+ intel_pstate_hwp_boost_down(cpu);
+ cpu->hwp_boost_active = false;
+ cpu->iowait_boost = false;
+ }
+ }
+ return;
+ }
+
+ cpu->last_update = time;
+
+ if (cpu->iowait_boost) {
+ cpu->hwp_boost_active = true;
+ if (smp_processor_id() == cpu->cpu)
+ intel_pstate_hwp_boost_up(cpu);
+ else
+ smp_call_function_single_async(cpu->cpu, &cpu->csd);
+ }
}
static inline void intel_pstate_calc_avg_perf(struct cpudata *cpu)
--
2.9.5
next prev parent reply other threads:[~2018-05-16 4:50 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 4:49 [RFC/RFT] [PATCH 00/10] Intel_pstate: HWP Dynamic performance boost Srinivas Pandruvada
2018-05-16 4:49 ` [RFC/RFT] [PATCH 01/10] x86,sched: Add support for frequency invariance Srinivas Pandruvada
2018-05-16 9:56 ` Peter Zijlstra
2018-05-16 4:49 ` [RFC/RFT] [PATCH 02/10] cpufreq: intel_pstate: Conditional frequency invariant accounting Srinivas Pandruvada
2018-05-16 7:16 ` Peter Zijlstra
2018-05-16 7:29 ` Peter Zijlstra
2018-05-16 9:07 ` Rafael J. Wysocki
2018-05-16 17:32 ` Srinivas Pandruvada
2018-05-16 15:19 ` Juri Lelli
2018-05-16 15:47 ` Peter Zijlstra
2018-05-16 16:31 ` Juri Lelli
2018-05-17 10:59 ` Juri Lelli
2018-05-17 15:04 ` Juri Lelli
2018-05-17 15:41 ` Srinivas Pandruvada
2018-05-17 16:16 ` Peter Zijlstra
2018-05-17 16:42 ` Srinivas Pandruvada
2018-05-17 16:56 ` Rafael J. Wysocki
2018-05-17 18:28 ` Peter Zijlstra
2018-05-18 7:36 ` Rafael J. Wysocki
2018-05-18 10:57 ` Patrick Bellasi
2018-05-18 11:29 ` Peter Zijlstra
2018-05-18 13:33 ` Patrick Bellasi
2018-05-30 16:57 ` Patrick Bellasi
2018-05-18 14:09 ` Valentin Schneider
2018-05-16 15:58 ` Srinivas Pandruvada
2018-05-16 4:49 ` [RFC/RFT] [PATCH 03/10] cpufreq: intel_pstate: Utility functions to boost HWP performance limits Srinivas Pandruvada
2018-05-16 7:22 ` Peter Zijlstra
2018-05-16 9:15 ` Rafael J. Wysocki
2018-05-16 10:43 ` Peter Zijlstra
2018-05-16 15:39 ` Srinivas Pandruvada
2018-05-16 15:41 ` Srinivas Pandruvada
2018-05-16 4:49 ` [RFC/RFT] [PATCH 04/10] cpufreq: intel_pstate: Add update_util_hook for HWP Srinivas Pandruvada
2018-05-16 4:49 ` Srinivas Pandruvada [this message]
2018-05-16 7:37 ` [RFC/RFT] [PATCH 05/10] cpufreq: intel_pstate: HWP boost performance on IO Wake Peter Zijlstra
2018-05-16 17:55 ` Srinivas Pandruvada
2018-05-17 8:19 ` Peter Zijlstra
2018-05-16 9:45 ` Rafael J. Wysocki
2018-05-16 19:28 ` Srinivas Pandruvada
2018-05-16 4:49 ` [RFC/RFT] [PATCH 06/10] cpufreq / sched: Add interface to get utilization values Srinivas Pandruvada
2018-05-16 6:40 ` Viresh Kumar
2018-05-16 22:25 ` Srinivas Pandruvada
2018-05-16 8:11 ` Peter Zijlstra
2018-05-16 22:40 ` Srinivas Pandruvada
2018-05-17 7:50 ` Peter Zijlstra
2018-05-16 4:49 ` [RFC/RFT] [PATCH 07/10] cpufreq: intel_pstate: HWP boost performance on busy task migrate Srinivas Pandruvada
2018-05-16 9:49 ` Rafael J. Wysocki
2018-05-16 20:59 ` Srinivas Pandruvada
2018-05-16 4:49 ` [RFC/RFT] [PATCH 08/10] cpufreq: intel_pstate: Dyanmically update busy pct Srinivas Pandruvada
2018-05-16 7:43 ` Peter Zijlstra
2018-05-16 7:47 ` Peter Zijlstra
2018-05-16 4:49 ` [RFC/RFT] [PATCH 09/10] cpufreq: intel_pstate: New sysfs entry to control HWP boost Srinivas Pandruvada
2018-05-16 4:49 ` [RFC/RFT] [PATCH 10/10] cpufreq: intel_pstate: enable boost for SKX Srinivas Pandruvada
2018-05-16 7:49 ` Peter Zijlstra
2018-05-16 15:46 ` Srinivas Pandruvada
2018-05-16 15:54 ` Peter Zijlstra
2018-05-17 0:52 ` Srinivas Pandruvada
2018-05-16 6:49 ` [RFC/RFT] [PATCH 00/10] Intel_pstate: HWP Dynamic performance boost Juri Lelli
2018-05-16 15:43 ` Srinivas Pandruvada
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=20180516044911.28797-6-srinivas.pandruvada@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=bp@suse.de \
--cc=juri.lelli@arm.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mgorman@techsingularity.net \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=viresh.kumar@linaro.org \
--cc=x86@kernel.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).