diff mbox

turbostat: fix -S on UP systems

Message ID 20180716132626.163661-1-dedekind1@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Artem Bityutskiy July 16, 2018, 1:26 p.m. UTC
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Turbostat -S option makes the tool print only the summary line and no per-CPU
lines, and this is a useful feature. It does not, however, work as expected on
a single core system and this patch fixes the problem. The patch is a trivial
one-liner and I'll skip explaining how it works. Here is what a non-patched
turbostat prints on a UP system (a 2S IvyBridge Xeon with all but one CPUs offline):

$ turbostat -S -n2
... nip...
cpu0: MSR_PKGC7_IRTL: 0x00000000 (NOTvalid, 0 ns)
CPU	Avg_MHz	Busy%	Bzy_MHz	TSC_MHz	IRQ	SMI	POLL	C1   ...snip...
CPU	Avg_MHz	Busy%	Bzy_MHz	TSC_MHz	IRQ	SMI	POLL	C1   ...snip...

With this patch:

$turbostat -S -n2
...snip...
cpu0: MSR_PKGC7_IRTL: 0x00000000 (NOTvalid, 0 ns)
Avg_MHz	Busy%	Bzy_MHz	TSC_MHz	IRQ	SMI	POLL	C1	C1E  ...snip...
2	0.07	3000	2700	153	0	0	19	2    ...snip...
3	0.10	3000	2700	239	0	0	16	0    ...snip...

Change-Id: I00358bdacf9b309962771ce28e328e5a3409321f
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
---
 turbostat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/turbostat.c b/turbostat.c
index 4d14bbb..9013051 100644
--- a/turbostat.c
+++ b/turbostat.c
@@ -1169,7 +1169,7 @@  void format_all_counters(struct thread_data *t, struct core_data *c, struct pkg_
 
 	printed = 1;
 
-	if (summary_only)
+	if (summary_only && topo.num_cpus > 1)
 		return;
 
 	for_all_cpus(format_counters, t, c, p);