Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane

From: Linux Kernel Mailing List <linux-kernel <at> vger.kernel.org>
Subject: tools/power turbostat: calculate TSC frequency from CPUID(0x15) on SKL
Newsgroups: gmane.linux.kernel.commits.head
Date: Sunday 19th April 2015 22:02:55 UTC (over 3 years ago)
Gitweb:     http://git.kernel.org/linus/;a=commit;h=8a5bdf41d2c027c1e4ad62bc4f96f3fdf82070ba
Commit:     8a5bdf41d2c027c1e4ad62bc4f96f3fdf82070ba
Parent:     40ee8e3b9dc8917e6077dde6a49c7a71d63b0231
Refname:    refs/heads/master
Author:     Len Brown 
AuthorDate: Wed Apr 1 21:02:57 2015 -0400
Committer:  Len Brown 
CommitDate: Sat Apr 18 14:20:52 2015 -0400

    tools/power turbostat: calculate TSC frequency from CPUID(0x15) on SKL
    
    turbostat --debug
    ...
    CPUID(0x15): eax_crystal: 2 ebx_tsc: 100 ecx_crystal_hz: 0
    TSC: 1200 MHz (24000000 Hz * 100 / 2 / 1000000)
    
    Signed-off-by: Len Brown 
---
 tools/power/x86/turbostat/turbostat.c | 39
++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/tools/power/x86/turbostat/turbostat.c
b/tools/power/x86/turbostat/turbostat.c
index 064749d..203d45d 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -89,6 +89,8 @@ double rapl_joule_counter_range;
 unsigned int do_core_perf_limit_reasons;
 unsigned int do_gfx_perf_limit_reasons;
 unsigned int do_ring_perf_limit_reasons;
+unsigned int crystal_hz;
+unsigned long long tsc_hz;
 
 #define RAPL_PKG		(1 << 0)
 					/* 0x610 MSR_PKG_POWER_LIMIT */
@@ -2496,6 +2498,41 @@ void process_cpuid()
 			do_ptm ? "" : "No ",
 			has_epb ? "" : "No ");
 
+	if (max_level > 0x15) {
+		unsigned int eax_crystal;
+		unsigned int ebx_tsc;
+
+		/*
+		 * CPUID 15H TSC/Crystal ratio, possibly Crystal Hz
+		 */
+		eax_crystal = ebx_tsc = crystal_hz = edx = 0;
+		__get_cpuid(0x15, &eax_crystal, &ebx_tsc, &crystal_hz, &edx);
+
+		if (ebx_tsc != 0) {
+
+			if (debug && (ebx != 0))
+				fprintf(stderr, "CPUID(0x15): eax_crystal: %d ebx_tsc: %d
ecx_crystal_hz: %d\n",
+					eax_crystal, ebx_tsc, crystal_hz);
+
+			if (crystal_hz == 0)
+				switch(model) {
+				case 0x4E:	/* SKL */
+				case 0x5E:	/* SKL */
+					crystal_hz = 24000000;	/* 24 MHz */
+					break;
+				default:
+					crystal_hz = 0;
+			}
+
+			if (crystal_hz) {
+				tsc_hz =  (unsigned long long) crystal_hz * ebx_tsc / eax_crystal;
+				if (debug)
+					fprintf(stderr, "TSC: %lld MHz (%d Hz * %d / %d / 1000000)\n",
+						tsc_hz / 1000000, crystal_hz, ebx_tsc,  eax_crystal);
+			}
+		}
+	}
+
 	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);
@@ -2834,7 +2871,7 @@ int get_and_dump_counters(void)
 }
 
 void print_version() {
-	fprintf(stderr, "turbostat version 4.3 24 Mar, 2015"
+	fprintf(stderr, "turbostat version 4.4 2 Apr, 2015"
 		" - Len Brown \n");
 }
 
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head"
in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
 
CD: 33ms