Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix patch: fix kbl performance
  • Loading branch information
miguelinux committed Feb 2, 2017
1 parent 55702bf commit c5b4f14
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 87 deletions.
@@ -1,83 +1,85 @@
fix kbl performance

There are complaints of performance issues, when busy workloads are
executed on Kaby Lake desktop systems. Even 100% busy workload will not
lead to max turbo frequency with default energy performance setting.

The reason for this is that OEM's decided to turn on energy efficiency
optimization feature. When this is enabled, an optimum energy efficient max
P-State is calculated based on the current energy performance preference
setting. This is good for performance/watt, but this will result in some
loss of performance.

This change disables this energy efficiency optimization feature for
Kaby Lake desktop CPU models in HWP mode only as these systems tend to
care more about performance than power.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/cpufreq/intel_pstate.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index efa7754..48592a9 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1344,6 +1344,25 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata)
cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
}

+#define MSR_IA32_POWER_CTL_BIT_EE 19
+
+/* Disable energy efficiency optimization */
+static void intel_pstate_disable_ee(int cpu)
+{
+ u64 power_ctl;
+ int ret;
+
+ ret = rdmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, &power_ctl);
+ if (ret)
+ return;
+
+ if (!(power_ctl & BIT(MSR_IA32_POWER_CTL_BIT_EE))) {
+ pr_info("Disabling energy efficiency optimization %d\n", cpu);
+ power_ctl |= BIT(MSR_IA32_POWER_CTL_BIT_EE);
+ wrmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, power_ctl);
+ }
+}
+
static int atom_get_min_pstate(void)
{
u64 value;
@@ -1980,6 +1999,11 @@ static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] __initconst = {
{}
};

+static const struct x86_cpu_id intel_pstate_cpu_ee_disable_ids[] = {
+ ICPU(INTEL_FAM6_KABYLAKE_DESKTOP, core_params),
+ {}
+};
+
static int intel_pstate_init_cpu(unsigned int cpunum)
{
struct cpudata *cpu;
@@ -2010,6 +2034,12 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
cpu->cpu = cpunum;

if (hwp_active) {
+ const struct x86_cpu_id *id;
+
+ id = x86_match_cpu(intel_pstate_cpu_ee_disable_ids);
+ if (id)
+ intel_pstate_disable_ee(cpunum);
+
intel_pstate_hwp_enable(cpu);
pid_params.sample_rate_ms = 50;
pid_params.sample_rate_ns = 50 * NSEC_PER_MSEC;
--
2.7.4

-------------------------------------
linux-power-mgmt@eclists.intel.com
https://eclists.intel.com/sympa/info/linux-power-mgmt
Unsubscribe by sending email to sympa@eclists.intel.com with subject "Unsubscribe linux-power-mgmt"
From 890d259c9a783e577775adef73c621416e321229 Mon Sep 17 00:00:00 2001
From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Date: Wed, 1 Feb 2017 18:02:00 -0600
Subject: [PATCH] cpufreq: intel_pstate: Disable energy efficiency optimization

fix kbl performance

There are complaints of performance issues, when busy workloads are
executed on Kaby Lake desktop systems. Even 100% busy workload will not
lead to max turbo frequency with default energy performance setting.

The reason for this is that OEM's decided to turn on energy efficiency
optimization feature. When this is enabled, an optimum energy efficient max
P-State is calculated based on the current energy performance preference
setting. This is good for performance/watt, but this will result in some
loss of performance.

This change disables this energy efficiency optimization feature for
Kaby Lake desktop CPU models in HWP mode only as these systems tend to
care more about performance than power.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Miguel Bernal Marin <miguel.bernal.marin@linux.intel.com>
---
drivers/cpufreq/intel_pstate.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 4737520ec823..9e7a5344220c 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -820,6 +820,25 @@ static void intel_pstate_hwp_enable(struct cpudata *cpudata)
wrmsrl_on_cpu(cpudata->cpu, MSR_PM_ENABLE, 0x1);
}

+#define MSR_IA32_POWER_CTL_BIT_EE 19
+
+/* Disable energy efficiency optimization */
+static void intel_pstate_disable_ee(int cpu)
+{
+ u64 power_ctl;
+ int ret;
+
+ ret = rdmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, &power_ctl);
+ if (ret)
+ return;
+
+ if (!(power_ctl & BIT(MSR_IA32_POWER_CTL_BIT_EE))) {
+ pr_info("Disabling energy efficiency optimization %d\n", cpu);
+ power_ctl |= BIT(MSR_IA32_POWER_CTL_BIT_EE);
+ wrmsrl_on_cpu(cpu, MSR_IA32_POWER_CTL, power_ctl);
+ }
+}
+
static int atom_get_min_pstate(void)
{
u64 value;
@@ -1420,6 +1439,11 @@ static const struct x86_cpu_id intel_pstate_cpu_oob_ids[] __initconst = {
{}
};

+static const struct x86_cpu_id intel_pstate_cpu_ee_disable_ids[] = {
+ ICPU(INTEL_FAM6_KABYLAKE_DESKTOP, core_params),
+ {}
+};
+
static int intel_pstate_init_cpu(unsigned int cpunum)
{
struct cpudata *cpu;
@@ -1435,6 +1459,12 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
cpu->cpu = cpunum;

if (hwp_active) {
+ const struct x86_cpu_id *id;
+
+ id = x86_match_cpu(intel_pstate_cpu_ee_disable_ids);
+ if (id)
+ intel_pstate_disable_ee(cpunum);
+
intel_pstate_hwp_enable(cpu);
pid_params.sample_rate_ms = 50;
pid_params.sample_rate_ns = 50 * NSEC_PER_MSEC;
--
2.11.0

6 changes: 3 additions & 3 deletions linux.spec
Expand Up @@ -2,7 +2,7 @@ Name: linux
# note to self: Linus releases need to be named 4.x.0 not 4.x or various
# things break
Version: 4.9.7
Release: 304
Release: 305
License: GPL-2.0
Summary: The Linux kernel
Url: http://www.kernel.org/
Expand Down Expand Up @@ -35,6 +35,7 @@ Patch0001: cve-2016-8632.patch

# 00XY: Mainline patches, upstream backports
Patch0011: 0011-drm-i915-fbc-sanitize-fbc-GEN-greater-than-9.patch
Patch0012: 0012-cpufreq-intel_pstate-Disable-energy-efficiency-optim.patch

# Serie 01XX: Clear Linux patches
Patch0101: 0101-kvm-silence-kvm-unhandled-rdmsr.patch
Expand All @@ -61,7 +62,6 @@ Patch0121: 0121-e1000e-change-default-policy.patch
Patch0122: 0122-ipv4-tcp-allow-the-memory-tuning-for-tcp-to-go-a-lit.patch
Patch0123: 0123-igb-no-runtime-pm-to-fix-reboot-oops.patch
Patch0124: 0124-tweak-perfbias.patch
Patch0125: kbl-ee-msr-setting.patch

# Serie XYYY: Extra features modules

Expand Down Expand Up @@ -92,6 +92,7 @@ Linux kernel extra files

# 00XY Mainline patches, upstream backports
%patch0011 -p1
%patch0012 -p1

# 01XX Clear Linux patches
%patch0101 -p1
Expand All @@ -118,7 +119,6 @@ Linux kernel extra files
%patch0122 -p1
%patch0123 -p1
%patch0124 -p1
%patch0125 -p1

# Serie XYYY: Extra features modules

Expand Down
2 changes: 1 addition & 1 deletion release
@@ -1 +1 @@
303
305

0 comments on commit c5b4f14

Please sign in to comment.