Skip to contentSkip to conversation

turbostat tool update for Linux-3.8

PATCH In review Len Brown 2 participants 11 messages Nov 14, 2012 – Dec 17, 2012

Subsystems (2)
lore
Share & tools
lore

Len Brown

author maintainer
#0 lore raw

Here are some turbostat patches I have staged. The 1st two I've requested be pulled into 3.7, the rest are for 3.8

The final patch allows turbostat to print Watts as measured by hardware RAPL counters -- something that people have been asking for.

Please let me know if you see troubles with any of these patches.

thanks,
Len Brown, Intel Open Source Technology Center

author maintainer
#1 lore raw

PATCH 1/7 tools/power turbostat: Repair Segmentation fault when using -i option

From: Len Brown <[email protected]>

Fix regression caused by commit 8e180f3cb6b7510a3bdf14e16ce87c9f5d86f102 (tools/power turbostat: add [-d MSR#][-D MSR#] options to print counter deltas)

---
 tools/power/x86/turbostat/turbostat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +1 -1
index 2655ae9..9942dee 100644
@@ -1594,7 +1594,7 @@ void cmdline(int argc, char **argv)
 
 	progname = argv[0];
 
-	while ((opt = getopt(argc, argv, "+pPSvisc:sC:m:M:")) != -1) {
+	while ((opt = getopt(argc, argv, "+pPSvi:sc:sC:m:M:")) != -1) {
 		switch (opt) {
 		case 'p':
 			show_core_only++;
Signature · 1 line
1.8.0
author maintainer
#2 lore raw

PATCH 2/7 tools/power turbostat: graceful fail on garbage input

In reply to Len Brown

From: Len Brown <[email protected]>

When invald MSR's are specified on the command line, turbostat should simply print an error and exit.

---
 tools/power/x86/turbostat/turbostat.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
tools/power/x86/turbostat/turbostat.c +18 -8
index 9942dee..ea095ab 100644
@@ -206,8 +206,10 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr)
 	retval = pread(fd, msr, sizeof *msr, offset);
 	close(fd);
 
-	if (retval != sizeof *msr)
+	if (retval != sizeof *msr) {
+		fprintf(stderr, "%s offset 0x%zx read failed\n", pathname, offset);
 		return -1;
+	}
 
 	return 0;
 }
@@ -1101,7 +1103,9 @@ void turbostat_loop()
 
 restart:
 	retval = for_all_cpus(get_counters, EVEN_COUNTERS);
-	if (retval) {
+	if (retval < -1) {
+		exit(retval);
+	} else if (retval == -1) {
 		re_initialize();
 		goto restart;
 	}
@@ -1114,7 +1118,9 @@ restart:
 		}
 		sleep(interval_sec);
 		retval = for_all_cpus(get_counters, ODD_COUNTERS);
-		if (retval) {
+		if (retval < -1) {
+			exit(retval);
+		} else if (retval == -1) {
 			re_initialize();
 			goto restart;
 		}
@@ -1126,7 +1132,9 @@ restart:
 		flush_stdout();
 		sleep(interval_sec);
 		retval = for_all_cpus(get_counters, EVEN_COUNTERS);
-		if (retval) {
+		if (retval < -1) {
+			exit(retval);
+		} else if (retval == -1) {
 			re_initialize();
 			goto restart;
 		}
@@ -1545,8 +1553,11 @@ void turbostat_init()
 int fork_it(char **argv)
 {
 	pid_t child_pid;
+	int status;
 
-	for_all_cpus(get_counters, EVEN_COUNTERS);
+	status = for_all_cpus(get_counters, EVEN_COUNTERS);
+	if (status)
+		exit(status);
 	/* clear affinity side-effect of get_counters() */
 	sched_setaffinity(0, cpu_present_setsize, cpu_present_set);
 	gettimeofday(&tv_even, (struct timezone *)NULL);
@@ -1556,7 +1567,6 @@ int fork_it(char **argv)
 		/* child */
 		execvp(argv[0], argv);
 	} else {
-		int status;
 
 		/* parent */
 		if (child_pid == -1) {
@@ -1568,7 +1578,7 @@ int fork_it(char **argv)
 		signal(SIGQUIT, SIG_IGN);
 		if (waitpid(child_pid, &status, 0) == -1) {
 			perror("wait");
-			exit(1);
+			exit(status);
 		}
 	}
 	/*
@@ -1585,7 +1595,7 @@ int fork_it(char **argv)
 
 	fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0);
 
-	return 0;
+	return status;
 }
 
 void cmdline(int argc, char **argv)
Signature · 1 line
1.8.0
author maintainer
#3 lore raw

PATCH 3/7 tools/power/x86/turbostat: use kernel MSR #defines

In reply to Len Brown

From: Len Brown <[email protected]>

Now that turbostat is built in the kernel tree,
it can share MSR #defines with the kernel.

---
 arch/x86/include/asm/msr-index.h      | 12 ++++++++++++
 tools/power/x86/turbostat/Makefile    |  1 +
 tools/power/x86/turbostat/turbostat.c | 26 +++++++-------------------
 3 files changed, 20 insertions(+), 19 deletions(-)
arch/x86/include/asm/msr-index.h +12 -0
index 7f0edce..c9775a3 100644
@@ -35,6 +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_NHM_SNB_PKG_CST_CFG_CTL	0x000000e2
 #define NHM_C3_AUTO_DEMOTE		(1UL << 25)
@@ -55,6 +56,8 @@
 
 #define MSR_OFFCORE_RSP_0		0x000001a6
 #define MSR_OFFCORE_RSP_1		0x000001a7
+#define MSR_NHM_TURBO_RATIO_LIMIT	0x000001ad
+#define MSR_IVT_TURBO_RATIO_LIMIT	0x000001ae
 
 #define MSR_LBR_SELECT			0x000001c8
 #define MSR_LBR_TOS			0x000001c9
@@ -103,6 +106,15 @@
 #define MSR_IA32_MC0_ADDR		0x00000402
 #define MSR_IA32_MC0_MISC		0x00000403
 
+/* C-state Residency Counters */
+#define MSR_PKG_C3_RESIDENCY		0x000003f8
+#define MSR_PKG_C6_RESIDENCY		0x000003f9
+#define MSR_PKG_C7_RESIDENCY		0x000003fa
+#define MSR_CORE_C3_RESIDENCY		0x000003fc
+#define MSR_CORE_C6_RESIDENCY		0x000003fd
+#define MSR_CORE_C7_RESIDENCY		0x000003fe
+#define MSR_PKG_C2_RESIDENCY		0x0000060d
+
 #define MSR_AMD64_MC0_MASK		0xc0010044
 
 #define MSR_IA32_MCx_CTL(x)		(MSR_IA32_MC0_CTL + 4*(x))
tools/power/x86/turbostat/Makefile +1 -0
index f856495..51880e8 100644
@@ -1,5 +1,6 @@
 turbostat : turbostat.c
 CFLAGS +=	-Wall
+CFLAGS +=	-I../../../../arch/x86/include/
 
 clean :
 	rm -f turbostat
tools/power/x86/turbostat/turbostat.c +7 -19
index ea095ab..3c063a0 100644
@@ -20,6 +20,7 @@
  */
 
 #define _GNU_SOURCE
+#include <asm/msr.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
@@ -35,19 +36,6 @@
 #include <ctype.h>
 #include <sched.h>
 
-#define MSR_NEHALEM_PLATFORM_INFO	0xCE
-#define MSR_NEHALEM_TURBO_RATIO_LIMIT	0x1AD
-#define MSR_IVT_TURBO_RATIO_LIMIT	0x1AE
-#define MSR_APERF	0xE8
-#define MSR_MPERF	0xE7
-#define MSR_PKG_C2_RESIDENCY	0x60D	/* SNB only */
-#define MSR_PKG_C3_RESIDENCY	0x3F8
-#define MSR_PKG_C6_RESIDENCY	0x3F9
-#define MSR_PKG_C7_RESIDENCY	0x3FA	/* SNB only */
-#define MSR_CORE_C3_RESIDENCY	0x3FC
-#define MSR_CORE_C6_RESIDENCY	0x3FD
-#define MSR_CORE_C7_RESIDENCY	0x3FE	/* SNB only */
-
 char *proc_stat = "/proc/stat";
 unsigned int interval_sec = 5;	/* set with -i interval_sec */
 unsigned int verbose;		/* set with -v */
@@ -674,9 +662,9 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
 	t->tsc = rdtsc();	/* we are running on local CPU of interest */
 
 	if (has_aperf) {
-		if (get_msr(cpu, MSR_APERF, &t->aperf))
+		if (get_msr(cpu, MSR_IA32_APERF, &t->aperf))
 			return -3;
-		if (get_msr(cpu, MSR_MPERF, &t->mperf))
+		if (get_msr(cpu, MSR_IA32_MPERF, &t->mperf))
 			return -4;
 	}
 
@@ -742,10 +730,10 @@ void print_verbose_header(void)
 	if (!do_nehalem_platform_info)
 		return;
 
-	get_msr(0, MSR_NEHALEM_PLATFORM_INFO, &msr);
+	get_msr(0, MSR_NHM_PLATFORM_INFO, &msr);
 
 	if (verbose > 1)
-		fprintf(stderr, "MSR_NEHALEM_PLATFORM_INFO: 0x%llx\n", msr);
+		fprintf(stderr, "MSR_NHM_PLATFORM_INFO: 0x%llx\n", msr);
 
 	ratio = (msr >> 40) & 0xFF;
 	fprintf(stderr, "%d * %.0f = %.0f MHz max efficiency\n",
@@ -808,10 +796,10 @@ print_nhm_turbo_ratio_limits:
 	if (!do_nehalem_turbo_ratio_limit)
 		return;
 
-	get_msr(0, MSR_NEHALEM_TURBO_RATIO_LIMIT, &msr);
+	get_msr(0, MSR_NHM_TURBO_RATIO_LIMIT, &msr);
 
 	if (verbose > 1)
-		fprintf(stderr, "MSR_NEHALEM_TURBO_RATIO_LIMIT: 0x%llx\n", msr);
+		fprintf(stderr, "MSR_NHM_TURBO_RATIO_LIMIT: 0x%llx\n", msr);
 
 	ratio = (msr >> 56) & 0xFF;
 	if (ratio)
Signature · 1 line
1.8.0
author maintainer
#4 lore raw

PATCH 4/7 x86 power: define RAPL MSRs

In reply to Len Brown

From: Len Brown <[email protected]>

The Run Time Average Power Limiting interface is currently model specific, present on Sandy Bridge and Ivy Bridge processors.

These #defines correspond to documentation in the latest "Intel® 64 and IA-32 Architectures Software Developer Manual", plus some typos in that document corrected.

---
 arch/x86/include/asm/msr-index.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
arch/x86/include/asm/msr-index.h +23 -0
index c9775a3..7d05006 100644
@@ -115,6 +115,29 @@
 #define MSR_CORE_C7_RESIDENCY		0x000003fe
 #define MSR_PKG_C2_RESIDENCY		0x0000060d
 
+/* Run Time Average Power Limiting (RAPL) Interface */
+
+#define MSR_RAPL_POWER_UNIT		0x00000606
+
+#define MSR_PKG_POWER_LIMIT		0x00000610
+#define MSR_PKG_ENERGY_STATUS		0x00000611
+#define MSR_PKG_PERF_STATUS		0x00000613
+#define MSR_PKG_POWER_INFO		0x00000614
+
+#define MSR_DRAM_POWER_LIMIT		0x00000618
+#define MSR_DRAM_ENERGY_STATUS		0x00000619
+#define MSR_DRAM_PERF_STATUS		0x0000061b
+#define MSR_DRAM_POWER_INFO		0x0000061c
+
+#define MSR_PP0_POWER_LIMIT		0x00000638
+#define MSR_PP0_ENERGY_STATUS		0x00000639
+#define MSR_PP0_POLICY			0x0000063a
+#define MSR_PP0_PERF_STATUS		0x0000063b
+
+#define MSR_PP1_POWER_LIMIT		0x00000640
+#define MSR_PP1_ENERGY_STATUS		0x00000641
+#define MSR_PP1_POLICY			0x00000642
+
 #define MSR_AMD64_MC0_MASK		0xc0010044
 
 #define MSR_IA32_MCx_CTL(x)		(MSR_IA32_MC0_CTL + 4*(x))
Signature · 1 line
1.8.0
author maintainer
#5 lore raw

PATCH 5/7 tools: Allow tools to be installed in a user specified location

In reply to Len Brown

From: Josh Boyer <[email protected]>

When building x86_energy_perf_policy or turbostat within the confines of a packaging system such as RPM, we need to be able to have it install to the buildroot and not the root filesystem of the build machine. This adds a DESTDIR variable that when set will act as a prefix for the install location of these tools.

---
 tools/power/x86/turbostat/Makefile              | 6 ++++--
 tools/power/x86/x86_energy_perf_policy/Makefile | 6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)
tools/power/x86/turbostat/Makefile +4 -2
index 51880e8..e79f794 100644
@@ -1,3 +1,5 @@
+DESTDIR ?=
+
 turbostat : turbostat.c
 CFLAGS +=	-Wall
 CFLAGS +=	-I../../../../arch/x86/include/
@@ -6,5 +8,5 @@ clean :
 	rm -f turbostat
 
 install :
-	install turbostat /usr/bin/turbostat
-	install turbostat.8 /usr/share/man/man8
+	install turbostat ${DESTDIR}/usr/bin/turbostat
+	install turbostat.8 ${DESTDIR}/usr/share/man/man8
tools/power/x86/x86_energy_perf_policy/Makefile +4 -2
index f458237..971c9ff 100644
@@ -1,8 +1,10 @@
+DESTDIR ?=
+
 x86_energy_perf_policy : x86_energy_perf_policy.c
 
 clean :
 	rm -f x86_energy_perf_policy
 
 install :
-	install x86_energy_perf_policy /usr/bin/
-	install x86_energy_perf_policy.8 /usr/share/man/man8/
+	install x86_energy_perf_policy ${DESTDIR}/usr/bin/
+	install x86_energy_perf_policy.8 ${DESTDIR}/usr/share/man/man8/
Signature · 1 line
1.8.0
author maintainer
#6 lore raw

PATCH 6/7 tools/power turbostat: prevent infinite loop on migration error path

In reply to Len Brown

From: Len Brown <[email protected]>

Turbostat assumed if it can't migrate to a CPU, then the CPU must have gone off-line and turbostat should re-initialize with the new topology.

But if turbostat can not migrate because it is restricted by a cpuset, then it will fail to migrate even after re-initialization, resulting in an infinite loop.

Spit out a warning when we can't migrate
and endure only 2 re-initialize cycles in a row
before giving up and exiting.

---
 tools/power/x86/turbostat/turbostat.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tools/power/x86/turbostat/turbostat.c +10 -1
index 3c063a0..77e76b1 100644
@@ -656,8 +656,10 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
 {
 	int cpu = t->cpu_id;
 
-	if (cpu_migrate(cpu))
+	if (cpu_migrate(cpu)) {
+		fprintf(stderr, "Could not migrate to CPU %d\n", cpu);
 		return -1;
+	}
 
 	t->tsc = rdtsc();	/* we are running on local CPU of interest */
 
@@ -1088,15 +1090,22 @@ int mark_cpu_present(int cpu)
 void turbostat_loop()
 {
 	int retval;
+	int restarted = 0;
 
 restart:
+	restarted++;
+
 	retval = for_all_cpus(get_counters, EVEN_COUNTERS);
 	if (retval < -1) {
 		exit(retval);
 	} else if (retval == -1) {
+		if (restarted > 1) {
+			exit(retval);
+		}
 		re_initialize();
 		goto restart;
 	}
+	restarted = 0;
 	gettimeofday(&tv_even, (struct timezone *)NULL);
 
 	while (1) {
Signature · 1 line
1.8.0
author maintainer
#7 lore raw

PATCH 7/7 tools/power turbostat: print Watts

In reply to Len Brown

From: Len Brown <[email protected]>

Intel's Sandy Bridge and Ivy Bridge processor generations support RAPL (Run-Time-Average-Power-Limiting). Per the Intel SDM (Intel® 64 and IA-32 Architectures Software Developer Manual)
RAPL provides hardware power information and control via MSRs (Model Specific Registers). RAPL MSRs are designed primarily as a method to implement power capping.
However, even if power capping is not enabled, the RAPL regsiters
are useful for monitoring system power and operation.

Turbostat now displays the information provided by reading RAPL MSRs. As always, turbostat never writes any MSRs.

turbostat's default display now includes Watts for hardware that supports RAPL:

[root@sandy]# turbostat
cor CPU    %c0  GHz  TSC    %c1    %c3    %c6    %c7   %pc2   %pc3 %pc6   %pc7  Pkg_W  Cor_W GFX_W
          0.07 0.80 2.29   0.13   0.00   0.00  99.80   0.43   0.00 0.72  98.16   3.49   0.12  0.14
  0   0   0.14 0.80 2.29   0.12   0.00   0.00  99.74   0.43   0.00 0.72  98.16   3.49   0.12  0.14
  0   4   0.04 0.80 2.29   0.22
  1   1   0.06 0.80 2.29   0.08   0.00   0.00  99.86
  1   5   0.03 0.80 2.29   0.10
  2   2   0.17 0.80 2.29   0.14   0.00   0.00  99.69
  2   6   0.03 0.79 2.29   0.28
  3   3   0.03 0.80 2.29   0.07   0.00   0.00  99.90
  3   7   0.04 0.80 2.29   0.06

The Pkg_W column shows Watts for each package (socket) in the system. On multi-socket systems, the system summary on the 1st row shows the total.

The Cor_W column shows Watts due to processors cores. Core_W is included in Pkg_W.

The optional GFX_W column shows Watts due to the graphics "un-core". GFX_W is included in Pkg_W.

The optional PKG_% column shows the % of time in the measurement interval that RAPL power limiting is in effect.

Note that the RAPL energy counters have some limitations.

First hardware updates the countesr about once every milli-second. This is fine for typical turbostat measurement intervals > 1 sec. However, when turbostat is used to measure events that approach 1ms, the counters are less useful.

Second, the energy counters are 32-bits long and subject to wrapping. For example, the counter increments in 15 micro-Joule units on my local server, and the part could (in theory) consume energy at its TDP specification of 130 Watts. Here the 32-bit Joule counter coult wrap as soon as 8 minutes.
Turbostat detects and handles up to 1 counter overflow per interval. But when the measurement interval exceeds the guaranteed counter range, we can't detect if more than 1 overflow occured. So in this case turbostat indicates that the results are in question by replacing the fractional part of the result with "**":

Pkg_W Cor_W GFX_W
3** 0** 0**

Third, the RAPL counters are energy (Joule) counters -- they sum up weighted events in the package to estimate energy consumed. They are not analong power (Watt) meters. In practice, they tend to under-count because they don't cover every possible use of energy in the package. Also, the accuracy of the RAPL counters will vary between product generations, and between SKU's in the same product generation.

turbostat's -v option now displays per-Package Thermal Design Power (TDP). This is the specification for the part's maximum power consumption. eg. on a 2-package SNB-Xeon system:

cpu0: 130.00 Watts Pkg Thermal Design Spec
cpu8: 130.00 Watts Pkg Thermal Design Spec

Finally, turbostat's -R option enables decoding and output of all RAPL registers on turbostat startup.

Increment turbostat version number to 3.

---
 tools/power/x86/turbostat/turbostat.8 |  35 ++--
 tools/power/x86/turbostat/turbostat.c | 339 +++++++++++++++++++++++++++++++++-
 2 files changed, 350 insertions(+), 24 deletions(-)
tools/power/x86/turbostat/turbostat.8 +19 -16
index e4d0690..8094caa 100644
@@ -31,6 +31,8 @@ The \fB-S\fP option limits output to a 1-line System Summary for each interval.
 .PP
 The \fB-v\fP option increases verbosity.
 .PP
+The \fB-R\fP option enables verbose RAPL register decoding on startup.
+.PP
 The \fB-s\fP option prints the SMI counter, equivalent to "-c 0x34"
 .PP
 The \fB-c MSR#\fP option includes the delta of the specified 32-bit MSR counter.
@@ -58,6 +60,10 @@ Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading T
 \fBTSC\fP average GHz that the TSC ran during the entire interval.
 \fB%c1, %c3, %c6, %c7\fP show the percentage residency in hardware core idle states.
 \fB%pc2, %pc3, %pc6, %pc7\fP percentage residency in hardware package idle states.
+\fBPkg_W\fP Watts consumed by the whole package.
+\fBCor_W\fP Watts consumed by the core part of the package.
+\fBGFX_W\fP Watts consumed by the Graphics part of the package.
+\fBPKG_%\fP percent of the interval that RAPL throttling was active.
 .fi
 .PP
 .SH EXAMPLE
@@ -66,25 +72,22 @@ Without any parameters, turbostat prints out counters ever 5 seconds.
 for turbostat to fork).
 
 The first row of statistics is a summary for the entire system.
-Note that the summary is a weighted average.
+For residency % columns, the summary is a weighted average.
+For Watts columns, the summary is a system total.
 Subsequent rows show per-CPU statistics.
 
 .nf
-[root@x980]# ./turbostat
-cor CPU    %c0  GHz  TSC    %c1    %c3    %c6   %pc3   %pc6
-          0.09 1.62 3.38   1.83   0.32  97.76   1.26  83.61
-  0   0   0.15 1.62 3.38  10.23   0.05  89.56   1.26  83.61
-  0   6   0.05 1.62 3.38  10.34
-  1   2   0.03 1.62 3.38   0.07   0.05  99.86
-  1   8   0.03 1.62 3.38   0.06
-  2   4   0.21 1.62 3.38   0.10   1.49  98.21
-  2  10   0.02 1.62 3.38   0.29
-  8   1   0.04 1.62 3.38   0.04   0.08  99.84
-  8   7   0.01 1.62 3.38   0.06
-  9   3   0.53 1.62 3.38   0.10   0.20  99.17
-  9   9   0.02 1.62 3.38   0.60
- 10   5   0.01 1.62 3.38   0.02   0.04  99.92
- 10  11   0.02 1.62 3.38   0.02
+[root@sandy]# ./turbostat
+cor CPU    %c0  GHz  TSC    %c1    %c3    %c6    %c7   %pc2   %pc3   %pc6   %pc7  Pkg_W  Cor_W GFX_W
+          0.07 0.80 2.29   0.13   0.00   0.00  99.80   0.43   0.00   0.72  98.16   3.49   0.12  0.14
+  0   0   0.14 0.80 2.29   0.12   0.00   0.00  99.74   0.43   0.00   0.72  98.16   3.49   0.12  0.14
+  0   4   0.04 0.80 2.29   0.22
+  1   1   0.06 0.80 2.29   0.08   0.00   0.00  99.86
+  1   5   0.03 0.80 2.29   0.10
+  2   2   0.17 0.80 2.29   0.14   0.00   0.00  99.69
+  2   6   0.03 0.79 2.29   0.28
+  3   3   0.03 0.80 2.29   0.07   0.00   0.00  99.90
+  3   7   0.04 0.80 2.29   0.06
 .fi
 .SH SUMMARY EXAMPLE
 The "-s" option prints the column headers just once,
tools/power/x86/turbostat/turbostat.c +331 -8

486 lines not on this page · raw message

Signature · 1 line
1.8.0
#8 lore raw

Re: [PATCH 7/7] tools/power turbostat: print Watts

Quoted 1 line · Len Brown

From: Len Brown <[email protected]>

...

tools/power/x86/turbostat/turbostat.c int main(int argc, char **argv) · line 1973

Quoted 9 lines
tools/power/x86/turbostat/turbostat.c +1 -1
@@ -1644,7 +1967,7 @@ int main(int argc, char **argv)
 	cmdline(argc, argv);
 
 	if (verbose > 1)
-		fprintf(stderr, "turbostat v2.1 October 6, 2012"
+		fprintf(stderr, "turbostat v3.0 November 14, 2012"
 			" - Len Brown <[email protected]>\n");
 
 	turbostat_init();

I applied these 7 patches in order to a the upstream kernel and this last hunk was rejected:

$ cat turbostat.c.rej
--- tools/power/x86/turbostat/turbostat.c
+++ tools/power/x86/turbostat/turbostat.c
@@ -1967,7 +2290,7 @@
 	cmdline(argc, argv);

if (verbose > 1)
- fprintf(stderr, "turbostat v2.1 October 6, 2012"
+ fprintf(stderr, "turbostat v3.0 November 14, 2012"
" - Len Brown <lenb@xxxxxxxxxx>\n");

turbostat_init();

-Betty

#9 lore raw
In reply to Len Brown
Quoted 9 lines · Len Brown

Here are some turbostat patches I have staged. The 1st two I've requested be pulled into 3.7, the rest are for 3.8

The final patch allows turbostat to print Watts as measured by hardware RAPL counters -- something that people have been asking for.

Please let me know if you see troubles with any of these patches.

Hi Len,

I tested out these patches on an IvyBridge system and see the new Watts fields. They look like reasonable numbers to me. I ran with the system idle and then with lookbusy -c 50 and saw the Watts increase. Is there anything else to do to validate the numbers? In one case I saw that the Pkg_W for the system was off by .01, e.g. socket 0 was 28.33 and socket 1 was 29.74 and the system total was 58.08 instead of 58.07. That is probably fine and just rounding up.

-Betty

author maintainer
#10 lore raw
Quoted 13 lines · Betty Dall
Quoted 9 lines · Len Brown

Here are some turbostat patches I have staged. The 1st two I've requested be pulled into 3.7, the rest are for 3.8

The final patch allows turbostat to print Watts as measured by hardware RAPL counters -- something that people have been asking for.

Please let me know if you see troubles with any of these patches.

Hi Len,

Quoted 7 lines

I tested out these patches on an IvyBridge system and see the new Watts fields. They look like reasonable numbers to me. I ran with the system idle and then with lookbusy -c 50 and saw the Watts increase. Is there anything else to do to validate the numbers? In one case I saw that the Pkg_W for the system was off by .01, e.g. socket 0 was 28.33 and socket 1 was 29.74 and the system total was 58.08 instead of 58.07. That is probably fine and just rounding up.

This is likely a result of printf truncation.
note that these numbers are added internally w/o that truncation, and then their sum is printed.

If the total system power is what you're looking for, note that you need to calibrate these numbers vs an external A/C watt meter. eg. add a base Watts to idle -- which covers things like fans and fixed power supply loss, then use a coefficient on the counter to handle factors such as power conversion loss, which tend to be somewhat linear with load.

With constant temperature, I've found this trivial curve fitting to be remarkably accurate.

eg. on a dual SNB Xeon box I have...

45 Watts + 1.25 * RAPL-Watt-Meter = System A/C watts within a couple %.

cheers,
-Len