All of lore.kernel.org
 help / color / mirror / Atom feed
* turbostat patches for 4.3
@ 2015-11-12  7:42 Len Brown
  2015-11-12  7:42 ` [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation Len Brown
  2015-11-14  0:43 ` turbostat patches for 4.3 Rafael J. Wysocki
  0 siblings, 2 replies; 8+ messages in thread
From: Len Brown @ 2015-11-12  7:42 UTC (permalink / raw)
  To: linux-pm

Hello Rafael,

Please pick up this small batch of turbostat patches.
As usual, they are available on my turbostat branch.

thanks!
-Len

[PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation
[PATCH 2/4] tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO
[PATCH 3/4] tools/power turbostat: use new name for MSR_PLATFORM_INFO
[PATCH 4/4] x86: remove unused definition of MSR_NHM_PLATFORM_INFO

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation
  2015-11-12  7:42 turbostat patches for 4.3 Len Brown
@ 2015-11-12  7:42 ` Len Brown
  2015-11-12  7:42   ` [PATCH 2/4] tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO Len Brown
                     ` (2 more replies)
  2015-11-14  0:43 ` turbostat patches for 4.3 Rafael J. Wysocki
  1 sibling, 3 replies; 8+ messages in thread
From: Len Brown @ 2015-11-12  7:42 UTC (permalink / raw)
  To: linux-pm; +Cc: Len Brown

From: Len Brown <len.brown@intel.com>

Bzy_MHz = TSC_delta*tsc_tweak/APERF_delta/MPERF_delta/measurement_interval

becomes...

Bzy_MHz = base_mhz/APERF_delta/MPERF_delta

on systems which support MSR_PLATFORM_INFO.

base_mhz is calculated directly from the base_ratio
reported in MSR_PLATFORM_INFO * bclk,
and bclk is discovered via MSR or cpuid.

This reduces the dependency of Bzy_MHz calculation on the TSC.
Previously, there were 4 TSC readings required in each calculation,
the raw TSC delta combined with the measurement_interval.
This also removes the "tsc_tweak" correction factor used when
TSC runs on a different base clock from the CPU's bclk.

After this change, tsc_tweak is used only for %Busy.

The end-result should be a Bzy_MHz result slightly less prone to jitter.

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

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index bde0ef1..346bb54 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -75,6 +75,7 @@ unsigned int aperf_mperf_multiplier = 1;
 int do_smi;
 double bclk;
 double base_hz;
+unsigned int has_base_hz;
 double tsc_tweak = 1.0;
 unsigned int show_pkg;
 unsigned int show_core;
@@ -96,6 +97,7 @@ unsigned int do_ring_perf_limit_reasons;
 unsigned int crystal_hz;
 unsigned long long tsc_hz;
 int base_cpu;
+double discover_bclk(unsigned int family, unsigned int model);
 
 #define RAPL_PKG		(1 << 0)
 					/* 0x610 MSR_PKG_POWER_LIMIT */
@@ -505,15 +507,22 @@ 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/tsc_tweak);
+			outp += sprintf(outp, "%8.2f",
+				100.0 * t->mperf/t->tsc/tsc_tweak);
 		else
 			outp += sprintf(outp, "********");
 	}
 
 	/* Bzy_MHz */
-	if (has_aperf)
-		outp += sprintf(outp, "%8.0f",
-			1.0 * t->tsc * tsc_tweak / units * t->aperf / t->mperf / interval_float);
+	if (has_aperf) {
+		if (has_base_hz)
+			outp += sprintf(outp, "%8.0f", base_hz /
+				units * t->aperf / t->mperf);
+		else
+			outp += sprintf(outp, "%8.0f",
+				1.0 * t->tsc / units * t->aperf /
+				t->mperf / interval_float);
+	}
 
 	/* TSC_MHz */
 	outp += sprintf(outp, "%8.0f", 1.0 * t->tsc/units/interval_float);
@@ -1158,12 +1167,6 @@ int phi_pkg_cstate_limits[16] = {PCL__0, PCL__2, PCL_6N, PCL_6R, 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;
 }
 
@@ -1821,6 +1824,7 @@ void check_permissions()
 int probe_nhm_msrs(unsigned int family, unsigned int model)
 {
 	unsigned long long msr;
+	unsigned int base_ratio;
 	int *pkg_cstate_limits;
 
 	if (!genuine_intel)
@@ -1829,6 +1833,8 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
 	if (family != 6)
 		return 0;
 
+	bclk = discover_bclk(family, model);
+
 	switch (model) {
 	case 0x1A:	/* Core i7, Xeon 5500 series - Bloomfield, Gainstown NHM-EP */
 	case 0x1E:	/* Core i7 and i5 Processor - Clarksfield, Lynnfield, Jasper Forest */
@@ -1871,9 +1877,13 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
 		return 0;
 	}
 	get_msr(base_cpu, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr);
-
 	pkg_cstate_limit = pkg_cstate_limits[msr & 0xF];
 
+	get_msr(base_cpu, MSR_NHM_PLATFORM_INFO, &msr);
+	base_ratio = (msr >> 8) & 0xFF;
+
+	base_hz = base_ratio * bclk * 1000000;
+	has_base_hz = 1;
 	return 1;
 }
 int has_nhm_turbo_ratio_limit(unsigned int family, unsigned int model)
@@ -2780,7 +2790,6 @@ void process_cpuid()
 	do_skl_residency = has_skl_msrs(family, model);
 	do_slm_cstates = is_slm(family, model);
 	do_knl_cstates  = is_knl(family, model);
-	bclk = discover_bclk(family, model);
 
 	rapl_probe(family, model);
 	perf_limit_reasons_probe(family, model);
@@ -3119,7 +3128,7 @@ int get_and_dump_counters(void)
 }
 
 void print_version() {
-	fprintf(stderr, "turbostat version 4.8 26-Sep, 2015"
+	fprintf(stderr, "turbostat version 4.9 19-Oct, 2015"
 		" - Len Brown <lenb@kernel.org>\n");
 }
 
-- 
2.6.2.450.g259b5e6


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO
  2015-11-12  7:42 ` [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation Len Brown
@ 2015-11-12  7:42   ` Len Brown
  2015-11-12  7:42   ` [PATCH 3/4] tools/power turbostat: use new name for MSR_PLATFORM_INFO Len Brown
  2015-11-12  7:42   ` [PATCH 4/4] x86: remove unused definition of MSR_NHM_PLATFORM_INFO Len Brown
  2 siblings, 0 replies; 8+ messages in thread
From: Len Brown @ 2015-11-12  7:42 UTC (permalink / raw)
  To: linux-pm; +Cc: Len Brown

From: Len Brown <len.brown@intel.com>

MSR_TURBO_ACTIVATION_RATIO: 0x00000016 (MAX_NON_TURBO_RATIO=6 lock=0)
should print all 7 bits of MAX_NON_TURBO_RATIO (in decimal):
MSR_TURBO_ACTIVATION_RATIO: 0x00000016 (MAX_NON_TURBO_RATIO=22 lock=0)

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

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 346bb54..32452a8 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1443,7 +1443,7 @@ dump_config_tdp(void)
 	
 	get_msr(base_cpu, MSR_TURBO_ACTIVATION_RATIO, &msr);
 	fprintf(stderr, "cpu%d: MSR_TURBO_ACTIVATION_RATIO: 0x%08llx (", base_cpu, msr);
-	fprintf(stderr, "MAX_NON_TURBO_RATIO=%d", (unsigned int)(msr) & 0xEF);
+	fprintf(stderr, "MAX_NON_TURBO_RATIO=%d", (unsigned int)(msr) & 0x7F);
 	fprintf(stderr, " lock=%d", (unsigned int)(msr >> 31) & 1);
 	fprintf(stderr, ")\n");
 }
-- 
2.6.2.450.g259b5e6


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] tools/power turbostat: use new name for MSR_PLATFORM_INFO
  2015-11-12  7:42 ` [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation Len Brown
  2015-11-12  7:42   ` [PATCH 2/4] tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO Len Brown
@ 2015-11-12  7:42   ` Len Brown
  2015-11-12  7:42   ` [PATCH 4/4] x86: remove unused definition of MSR_NHM_PLATFORM_INFO Len Brown
  2 siblings, 0 replies; 8+ messages in thread
From: Len Brown @ 2015-11-12  7:42 UTC (permalink / raw)
  To: linux-pm; +Cc: Len Brown

From: Len Brown <len.brown@intel.com>

MSR_PLATFORM_INFO is the new name for MSR_NHM_PLATFORM_INFO

no functional change

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

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 32452a8..96794f3 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -1176,9 +1176,9 @@ dump_nhm_platform_info(void)
 	unsigned long long msr;
 	unsigned int ratio;
 
-	get_msr(base_cpu, MSR_NHM_PLATFORM_INFO, &msr);
+	get_msr(base_cpu, MSR_PLATFORM_INFO, &msr);
 
-	fprintf(stderr, "cpu%d: MSR_NHM_PLATFORM_INFO: 0x%08llx\n", base_cpu, msr);
+	fprintf(stderr, "cpu%d: MSR_PLATFORM_INFO: 0x%08llx\n", base_cpu, msr);
 
 	ratio = (msr >> 40) & 0xFF;
 	fprintf(stderr, "%d * %.0f = %.0f MHz max efficiency frequency\n",
@@ -1810,7 +1810,7 @@ void check_permissions()
  *
  * MSR_SMI_COUNT                   0x00000034
  *
- * MSR_NHM_PLATFORM_INFO           0x000000ce
+ * MSR_PLATFORM_INFO               0x000000ce
  * MSR_NHM_SNB_PKG_CST_CFG_CTL     0x000000e2
  *
  * MSR_PKG_C3_RESIDENCY            0x000003f8
@@ -1879,7 +1879,7 @@ int probe_nhm_msrs(unsigned int family, unsigned int model)
 	get_msr(base_cpu, MSR_NHM_SNB_PKG_CST_CFG_CTL, &msr);
 	pkg_cstate_limit = pkg_cstate_limits[msr & 0xF];
 
-	get_msr(base_cpu, MSR_NHM_PLATFORM_INFO, &msr);
+	get_msr(base_cpu, MSR_PLATFORM_INFO, &msr);
 	base_ratio = (msr >> 8) & 0xFF;
 
 	base_hz = base_ratio * bclk * 1000000;
-- 
2.6.2.450.g259b5e6


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] x86: remove unused definition of MSR_NHM_PLATFORM_INFO
  2015-11-12  7:42 ` [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation Len Brown
  2015-11-12  7:42   ` [PATCH 2/4] tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO Len Brown
  2015-11-12  7:42   ` [PATCH 3/4] tools/power turbostat: use new name for MSR_PLATFORM_INFO Len Brown
@ 2015-11-12  7:42   ` Len Brown
  2 siblings, 0 replies; 8+ messages in thread
From: Len Brown @ 2015-11-12  7:42 UTC (permalink / raw)
  To: linux-pm; +Cc: Len Brown

From: Len Brown <len.brown@intel.com>

MSR_NHM_PLATFORM_INFO has been replaced by...
MSR_PLATFORM_INFO

Signed-off-by: Len Brown <len.brown@intel.com>
---
 arch/x86/include/asm/msr-index.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index b8c14bb..705c408 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -35,7 +35,7 @@
 #define MSR_IA32_PERFCTR0		0x000000c1
 #define MSR_IA32_PERFCTR1		0x000000c2
 #define MSR_FSB_FREQ			0x000000cd
-#define MSR_NHM_PLATFORM_INFO		0x000000ce
+#define MSR_PLATFORM_INFO		0x000000ce
 
 #define MSR_NHM_SNB_PKG_CST_CFG_CTL	0x000000e2
 #define NHM_C3_AUTO_DEMOTE		(1UL << 25)
@@ -44,7 +44,6 @@
 #define SNB_C1_AUTO_UNDEMOTE		(1UL << 27)
 #define SNB_C3_AUTO_UNDEMOTE		(1UL << 28)
 
-#define MSR_PLATFORM_INFO		0x000000ce
 #define MSR_MTRRcap			0x000000fe
 #define MSR_IA32_BBL_CR_CTL		0x00000119
 #define MSR_IA32_BBL_CR_CTL3		0x0000011e
-- 
2.6.2.450.g259b5e6


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: turbostat patches for 4.3
  2015-11-12  7:42 turbostat patches for 4.3 Len Brown
  2015-11-12  7:42 ` [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation Len Brown
@ 2015-11-14  0:43 ` Rafael J. Wysocki
  2015-11-19 23:46   ` Len Brown
  1 sibling, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2015-11-14  0:43 UTC (permalink / raw)
  To: Len Brown; +Cc: linux-pm

On Thursday, November 12, 2015 02:42:28 AM Len Brown wrote:
> Hello Rafael,

Hi,

> Please pick up this small batch of turbostat patches.
> As usual, they are available on my turbostat branch.
> 
> thanks!
> -Len
> 
> [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation
> [PATCH 2/4] tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO
> [PATCH 3/4] tools/power turbostat: use new name for MSR_PLATFORM_INFO
> [PATCH 4/4] x86: remove unused definition of MSR_NHM_PLATFORM_INFO

I pulled from your branch on Wednesday and there were only [1-2/4] on it then.
That's what went to Linus on that day.

Today, I've noticed that you rebased the branch and it's generating conflicts
for me when pulled, so instead of pulling from it I've applied [3-4/4] directly
and I'm going to push them to Linus for -rc2.

Thanks,
Rafael


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: turbostat patches for 4.3
  2015-11-14  0:43 ` turbostat patches for 4.3 Rafael J. Wysocki
@ 2015-11-19 23:46   ` Len Brown
  2015-11-20  0:23     ` Rafael J. Wysocki
  0 siblings, 1 reply; 8+ messages in thread
From: Len Brown @ 2015-11-19 23:46 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Linux PM list

linux-next looks fine, go ahead and push it.

all you missed in the refresh was some 80-column formatting
for checkpatch and a version number bump.

thanks,
-Len


On Fri, Nov 13, 2015 at 7:43 PM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Thursday, November 12, 2015 02:42:28 AM Len Brown wrote:
>> Hello Rafael,
>
> Hi,
>
>> Please pick up this small batch of turbostat patches.
>> As usual, they are available on my turbostat branch.
>>
>> thanks!
>> -Len
>>
>> [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation
>> [PATCH 2/4] tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO
>> [PATCH 3/4] tools/power turbostat: use new name for MSR_PLATFORM_INFO
>> [PATCH 4/4] x86: remove unused definition of MSR_NHM_PLATFORM_INFO
>
> I pulled from your branch on Wednesday and there were only [1-2/4] on it then.
> That's what went to Linus on that day.
>
> Today, I've noticed that you rebased the branch and it's generating conflicts
> for me when pulled, so instead of pulling from it I've applied [3-4/4] directly
> and I'm going to push them to Linus for -rc2.
>
> Thanks,
> Rafael
>



-- 
Len Brown, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: turbostat patches for 4.3
  2015-11-19 23:46   ` Len Brown
@ 2015-11-20  0:23     ` Rafael J. Wysocki
  0 siblings, 0 replies; 8+ messages in thread
From: Rafael J. Wysocki @ 2015-11-20  0:23 UTC (permalink / raw)
  To: Len Brown; +Cc: Rafael J. Wysocki, Linux PM list

On Fri, Nov 20, 2015 at 12:46 AM, Len Brown <lenb@kernel.org> wrote:
> linux-next looks fine, go ahead and push it.

I will, thanks!

Rafael

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-11-20  0:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12  7:42 turbostat patches for 4.3 Len Brown
2015-11-12  7:42 ` [PATCH 1/4] tools/power turbostat: simplify Bzy_MHz calculation Len Brown
2015-11-12  7:42   ` [PATCH 2/4] tools/power turbostat: bugfix: print MAX_NON_TURBO_RATIO Len Brown
2015-11-12  7:42   ` [PATCH 3/4] tools/power turbostat: use new name for MSR_PLATFORM_INFO Len Brown
2015-11-12  7:42   ` [PATCH 4/4] x86: remove unused definition of MSR_NHM_PLATFORM_INFO Len Brown
2015-11-14  0:43 ` turbostat patches for 4.3 Rafael J. Wysocki
2015-11-19 23:46   ` Len Brown
2015-11-20  0:23     ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.