diff mbox

[v2] turbostat: fix -S on UP systems

Message ID 20180716133925.186248-1-dedekind1@gmail.com (mailing list archive)
State Superseded, archived
Delegated to: Len Brown
Headers show

Commit Message

Artem Bityutskiy July 16, 2018, 1:39 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
...snip...
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...

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

 Changelog:
    v2: removed Change-ID.

Comments

Len Brown July 20, 2018, 6:46 p.m. UTC | #1
Thanks for noticing this issue, and reporting it with a fix.

I'm thinking I'll fix it this way in format_all_counters():

-       if (topo.num_cpus > 1)

since we compute the "average" anyway, even in the 1-cpu case, we
might as well consistently print it.
On Mon, Jul 16, 2018 at 9:39 AM Artem Bityutskiy <dedekind1@gmail.com> wrote:
>
> 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
> ...snip...
> 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...
>
> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> ---
>  turbostat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
>  Changelog:
>     v2: removed Change-ID.
>
> 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);
> --
> 2.14.4
>
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);