Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1233138 > unrolled thread

intel_idle and turbostat patches for Linux-4.3

Started byLen Brown <lenb@kernel.org>
First post2015-09-26 07:10 +0200
Last post2015-09-27 15:30 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  intel_idle and turbostat patches for Linux-4.3 Len Brown <lenb@kernel.org> - 2015-09-26 07:10 +0200
    [PATCH 3/4] tools/power turbostat: KNL workaround for %Busy and Avg_MHz Len Brown <lenb@kernel.org> - 2015-09-26 07:10 +0200
    [PATCH 1/4] intel_idle: Skylake Client Support - updated Len Brown <lenb@kernel.org> - 2015-09-26 07:10 +0200
    [PATCH 4/4] tools/power turbostat: SKL: Adjust for TSC difference from base frequency Len Brown <lenb@kernel.org> - 2015-09-26 07:10 +0200
    [PATCH 2/4] tools/power turbostat: IVB Xeon: fix --debug regression Len Brown <lenb@kernel.org> - 2015-09-26 07:10 +0200
    Re: intel_idle and turbostat patches for Linux-4.3 "Rafael J. Wysocki" <rjw@rjwysocki.net> - 2015-09-27 15:30 +0200

#1233138 — intel_idle and turbostat patches for Linux-4.3

FromLen Brown <lenb@kernel.org>
Date2015-09-26 07:10 +0200
Subjectintel_idle and turbostat patches for Linux-4.3
Message-ID<qcPUe-6X6-1@gated-at.bofh.it>
Hi Rafael,

The following patches are available on my "intel_idle"
and "turbostat" branches, as usual, plus here for review.

[PATCH 1/4] intel_idle: Skylake Client Support - updated

	Initial SKL intel_idle support went into 4.3-rc1.
	That patch works, but this patch makes it more optimal,
	under some conditions.

[PATCH 2/4] tools/power turbostat: IVB Xeon: fix --debug regression

	This is a regression fix for a 4.1-rc1 patch
	It was rude for turbostat to start failing on IVB-Xeon boxes.

[PATCH 3/4] tools/power turbostat: KNL workaround for %Busy and

	This works around a newly documented hardware quirk.

[PATCH 4/4] tools/power turbostat: SKL: Adjust for TSC difference

	This works around an accuracy error that initially
	looked insignificant, but on some configurations it will
	be big enough to be noticed and confuse users, so here
	we address it fully.

Thanks,
Len Brown, Intel Open Source Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1233139 — [PATCH 3/4] tools/power turbostat: KNL workaround for %Busy and Avg_MHz

FromLen Brown <lenb@kernel.org>
Date2015-09-26 07:10 +0200
Subject[PATCH 3/4] tools/power turbostat: KNL workaround for %Busy and Avg_MHz
Message-ID<qcPUe-6X6-3@gated-at.bofh.it>
In reply to#1233138
From: Hubert Chrzaniuk <hubert.chrzaniuk@intel.com>

KNL increments APERF and MPERF every 1024 clocks.
This is compliant with the architecture specification,
which requires that only the ratio of APERF/MPERF need be valid.

However, turbostat takes advantage of the fact that these
two MSRs increment every un-halted clock
at the actual and base frequency:

AVG_MHz = APERF_delta/measurement_interval

%Busy = MPERF_delta/TSC_delta

This quirk is needed for these calculations to also work on KNL,
which would otherwise show a value 1024x smaller than expected.

Signed-off-by: Hubert Chrzaniuk <hubert.chrzaniuk@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index e05d3033..d333c81 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -71,6 +71,7 @@ unsigned int extra_msr_offset32;
 unsigned int extra_msr_offset64;
 unsigned int extra_delta_offset32;
 unsigned int extra_delta_offset64;
+unsigned int aperf_mperf_multiplier = 1;
 int do_smi;
 double bclk;
 unsigned int show_pkg;
@@ -984,6 +985,8 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
 			return -3;
 		if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf))
 			return -4;
+		t->aperf = t->aperf * aperf_mperf_multiplier;
+		t->mperf = t->mperf * aperf_mperf_multiplier;
 	}
 
 	if (do_smi) {
@@ -2541,6 +2544,13 @@ int is_knl(unsigned int family, unsigned int model)
 	return 0;
 }
 
+unsigned int get_aperf_mperf_multiplier(unsigned int family, unsigned int model)
+{
+	if (is_knl(family, model))
+		return 1024;
+	return 1;
+}
+
 #define SLM_BCLK_FREQS 5
 double slm_freq_table[SLM_BCLK_FREQS] = { 83.3, 100.0, 133.3, 116.7, 80.0};
 
@@ -2742,6 +2752,9 @@ void process_cpuid()
 		}
 	}
 
+	if (has_aperf)
+		aperf_mperf_multiplier = get_aperf_mperf_multiplier(family, model);
+
 	do_nhm_platform_info = do_nhm_cstates = do_smi = probe_nhm_msrs(family, model);
 	do_snb_cstates = has_snb_msrs(family, model);
 	do_pc2 = do_snb_cstates && (pkg_cstate_limit >= PCL__2);
-- 
2.6.0.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1233140 — [PATCH 1/4] intel_idle: Skylake Client Support - updated

FromLen Brown <lenb@kernel.org>
Date2015-09-26 07:10 +0200
Subject[PATCH 1/4] intel_idle: Skylake Client Support - updated
Message-ID<qcPUf-6X6-11@gated-at.bofh.it>
In reply to#1233138
From: Len Brown <len.brown@intel.com>

Addition of PC9 state, and minor tweaks to existing PC6 and PC8 states.

Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/idle/intel_idle.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 3a3738f..cd4510a 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -620,7 +620,7 @@ static struct cpuidle_state skl_cstates[] = {
 		.name = "C6-SKL",
 		.desc = "MWAIT 0x20",
 		.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
-		.exit_latency = 75,
+		.exit_latency = 85,
 		.target_residency = 200,
 		.enter = &intel_idle,
 		.enter_freeze = intel_idle_freeze, },
@@ -636,11 +636,19 @@ static struct cpuidle_state skl_cstates[] = {
 		.name = "C8-SKL",
 		.desc = "MWAIT 0x40",
 		.flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
-		.exit_latency = 174,
+		.exit_latency = 200,
 		.target_residency = 800,
 		.enter = &intel_idle,
 		.enter_freeze = intel_idle_freeze, },
 	{
+		.name = "C9-SKL",
+		.desc = "MWAIT 0x50",
+		.flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 480,
+		.target_residency = 5000,
+		.enter = &intel_idle,
+		.enter_freeze = intel_idle_freeze, },
+	{
 		.name = "C10-SKL",
 		.desc = "MWAIT 0x60",
 		.flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
-- 
2.6.0.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1233142 — [PATCH 4/4] tools/power turbostat: SKL: Adjust for TSC difference from base frequency

FromLen Brown <lenb@kernel.org>
Date2015-09-26 07:10 +0200
Subject[PATCH 4/4] tools/power turbostat: SKL: Adjust for TSC difference from base frequency
Message-ID<qcPUe-6X6-7@gated-at.bofh.it>
In reply to#1233138
From: Len Brown <len.brown@intel.com>

On a Skylake with 1500MHz base frequency,
the TSC runs at 1512MHz.

This is because the TSC is no longer in the n*100 MHz BCLK domain,
but is now in the m*24MHz crystal clock domain. (24 MHz * 63 = 1512 MHz)

This adds error to several calculations in turbostat,
unless the TSC sample sizes are adjusted for this difference.

Note that calculations in the time domain are immune
from this issue, as the timing sub-system has already
calibrated the TSC against a known wall clock.

AVG_MHz = APERF_delta/measurement_interval

	need no adjustment.  APERF_delta is in the BCLK domain,
	and measurement_interval is in the time domain.

TSC_MHz  =  TSC_delta/measurement_interval

	needs no adjustment -- as we really do want to report
	the actual measured TSC delta here, and measurement_interval
	is in the accurate time domain.

%Busy = MPERF_delta/TSC_delta

	needs adjustment to use TSC_BCLK_DOMAIN_delta.
	TSC_BCLK_DOMAIN_delta = TSC_delta * base_hz / tsc_hz

Bzy_MHz = TSC_delta/APERF_delta/MPERF_delta/measurement_interval

	need adjustment as above.

No other metrics in turbostat need to be adjusted.

Before:

     CPU Avg_MHz   %Busy Bzy_MHz TSC_MHz
       -     550   24.84    2216    1512
       0    2191   98.73    2219    1514
       2       0    0.01    2130    1512
       1       9    0.43    2016    1512
       3       2    0.08    2016    1512

After:

     CPU Avg_MHz   %Busy Bzy_MHz TSC_MHz
       -     550   25.05    2198    1512
       0    2190   99.62    2199    1512
       2       0    0.01    2152    1512
       1       9    0.46    2000    1512
       3       2    0.10    2000    1512

Note that in this example, the "Before" Bzy_MHz
was reported as exceeding the 2200 max turbo rate.
Also, even a pinned spin loop would not be reported
as over 99% busy.

Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index d333c81..31d756b 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -74,6 +74,8 @@ unsigned int extra_delta_offset64;
 unsigned int aperf_mperf_multiplier = 1;
 int do_smi;
 double bclk;
+double base_hz;
+double tsc_tweak = 1.0;
 unsigned int show_pkg;
 unsigned int show_core;
 unsigned int show_cpu;
@@ -503,7 +505,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
 	/* %Busy */
 	if (has_aperf) {
 		if (!skip_c0)
-			outp += sprintf(outp, "%8.2f", 100.0 * t->mperf/t->tsc);
+			outp += sprintf(outp, "%8.2f", 100.0 * t->mperf/t->tsc/tsc_tweak);
 		else
 			outp += sprintf(outp, "********");
 	}
@@ -511,7 +513,7 @@ int format_counters(struct thread_data *t, struct core_data *c,
 	/* Bzy_MHz */
 	if (has_aperf)
 		outp += sprintf(outp, "%8.0f",
-			1.0 * t->tsc / units * t->aperf / t->mperf / interval_float);
+			1.0 * t->tsc * tsc_tweak / units * t->aperf / t->mperf / interval_float);
 
 	/* TSC_MHz */
 	outp += sprintf(outp, "%8.0f", 1.0 * t->tsc/units/interval_float);
@@ -1152,6 +1154,19 @@ int slv_pkg_cstate_limits[16] = {PCL__0, PCL__1, PCLRSV, PCLRSV, PCL__4, PCLRSV,
 int amt_pkg_cstate_limits[16] = {PCL__0, PCL__1, PCL__2, PCLRSV, PCLRSV, PCLRSV, PCL__6, PCL__7, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV};
 int phi_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, PCLRSV, PCLRSV, PCLRSV, PCLUNL, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV, PCLRSV};
 
+
+static void
+calculate_tsc_tweak()
+{
+	unsigned long long msr;
+	unsigned int base_ratio;
+
+	get_msr(base_cpu, MSR_NHM_PLATFORM_INFO, &msr);
+	base_ratio = (msr >> 8) & 0xFF;
+	base_hz = base_ratio * bclk * 1000000;
+	tsc_tweak = base_hz / tsc_hz;
+}
+
 static void
 dump_nhm_platform_info(void)
 {
@@ -2773,6 +2788,9 @@ void process_cpuid()
 	if (debug)
 		dump_cstate_pstate_config_info();
 
+	if (has_skl_msrs(family, model))
+		calculate_tsc_tweak();
+
 	return;
 }
 
-- 
2.6.0.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1233143 — [PATCH 2/4] tools/power turbostat: IVB Xeon: fix --debug regression

FromLen Brown <lenb@kernel.org>
Date2015-09-26 07:10 +0200
Subject[PATCH 2/4] tools/power turbostat: IVB Xeon: fix --debug regression
Message-ID<qcPUf-6X6-13@gated-at.bofh.it>
In reply to#1233138
From: Len Brown <len.brown@intel.com>

Staring in Linux-4.3-rc1,
commit 6fb3143b561c ("tools/power turbostat: dump CONFIG_TDP")
touches MSR 0x648, which is not supported on IVB-Xeon.
This results in "turbostat --debug" exiting on those systems:

turbostat: /dev/cpu/2/msr offset 0x648 read failed: Input/output error

Remove IVB-Xeon from the list of machines supporting with that MSR.

Signed-off-by: Len Brown <len.brown@intel.com>
---
 tools/power/x86/turbostat/turbostat.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 9655cb4..e05d3033 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1926,8 +1926,6 @@ int has_config_tdp(unsigned int family, unsigned int model)
 
 	switch (model) {
 	case 0x3A:	/* IVB */
-	case 0x3E:	/* IVB Xeon */
-
 	case 0x3C:	/* HSW */
 	case 0x3F:	/* HSX */
 	case 0x45:	/* HSW */
-- 
2.6.0.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1233662

From"Rafael J. Wysocki" <rjw@rjwysocki.net>
Date2015-09-27 15:30 +0200
Message-ID<qdkbD-8pw-5@gated-at.bofh.it>
In reply to#1233138
On Saturday, September 26, 2015 01:05:11 AM Len Brown wrote:
> Hi Rafael,

Hi Len,

> The following patches are available on my "intel_idle"
> and "turbostat" branches, as usual, plus here for review.

There's no intel_idle branch in your tree, but there is a cpuidle one
and I found the patch below in it, so I pulled from there.

> [PATCH 1/4] intel_idle: Skylake Client Support - updated
> 
> 	Initial SKL intel_idle support went into 4.3-rc1.
> 	That patch works, but this patch makes it more optimal,
> 	under some conditions.
> 
> [PATCH 2/4] tools/power turbostat: IVB Xeon: fix --debug regression
> 
> 	This is a regression fix for a 4.1-rc1 patch
> 	It was rude for turbostat to start failing on IVB-Xeon boxes.
> 
> [PATCH 3/4] tools/power turbostat: KNL workaround for %Busy and
> 
> 	This works around a newly documented hardware quirk.
> 
> [PATCH 4/4] tools/power turbostat: SKL: Adjust for TSC difference
> 
> 	This works around an accuracy error that initially
> 	looked insignificant, but on some configurations it will
> 	be big enough to be noticed and confuse users, so here
> 	we address it fully.

Pulled, thanks!

Will push to Linus for 4.3-rc4.

Thanks,
Rafael

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web