aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2012-02-06 18:37:16 -0500
committerLen Brown <len.brown@intel.com>2012-03-29 13:22:06 -0400
commite23da0370f80834e971142e50253f5b79be83631 (patch)
treebe64cb44ace74106e1515eef2e8dbdc88940d7d6 /tools/power
parentc16fa4f2ad19908a47c63d8fa436a1178438c7e7 (diff)
tools turbostat: add summary option
turbostat -s cuts down on the amount of output, per user request. also treak some output whitespace and the man page. Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'tools/power')
-rw-r--r--tools/power/x86/turbostat/turbostat.899
-rw-r--r--tools/power/x86/turbostat/turbostat.c90
2 files changed, 120 insertions, 69 deletions
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index 555c69a5592a..adf175f61496 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -4,11 +4,13 @@ turbostat \- Report processor frequency and idle statistics
4.SH SYNOPSIS 4.SH SYNOPSIS
5.ft B 5.ft B
6.B turbostat 6.B turbostat
7.RB [ "\-s" ]
7.RB [ "\-v" ] 8.RB [ "\-v" ]
8.RB [ "\-M MSR#" ] 9.RB [ "\-M MSR#" ]
9.RB command 10.RB command
10.br 11.br
11.B turbostat 12.B turbostat
13.RB [ "\-s" ]
12.RB [ "\-v" ] 14.RB [ "\-v" ]
13.RB [ "\-M MSR#" ] 15.RB [ "\-M MSR#" ]
14.RB [ "\-i interval_sec" ] 16.RB [ "\-i interval_sec" ]
@@ -25,6 +27,8 @@ supports an "invariant" TSC, plus the APERF and MPERF MSRs.
25on processors that additionally support C-state residency counters. 27on processors that additionally support C-state residency counters.
26 28
27.SS Options 29.SS Options
30The \fB-s\fP option prints only a 1-line summary for each sample interval.
31.PP
28The \fB-v\fP option increases verbosity. 32The \fB-v\fP option increases verbosity.
29.PP 33.PP
30The \fB-M MSR#\fP option dumps the specified MSR, 34The \fB-M MSR#\fP option dumps the specified MSR,
@@ -39,13 +43,14 @@ displays the statistics gathered since it was forked.
39.SH FIELD DESCRIPTIONS 43.SH FIELD DESCRIPTIONS
40.nf 44.nf
41\fBpk\fP processor package number. 45\fBpk\fP processor package number.
42\fBcr\fP processor core number. 46\fBcor\fP processor core number.
43\fBCPU\fP Linux CPU (logical processor) number. 47\fBCPU\fP Linux CPU (logical processor) number.
48Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology.
44\fB%c0\fP percent of the interval that the CPU retired instructions. 49\fB%c0\fP percent of the interval that the CPU retired instructions.
45\fBGHz\fP average clock rate while the CPU was in c0 state. 50\fBGHz\fP average clock rate while the CPU was in c0 state.
46\fBTSC\fP average GHz that the TSC ran during the entire interval. 51\fBTSC\fP average GHz that the TSC ran during the entire interval.
47\fB%c1, %c3, %c6\fP show the percentage residency in hardware core idle states. 52\fB%c1, %c3, %c6, %c7\fP show the percentage residency in hardware core idle states.
48\fB%pc3, %pc6\fP percentage residency in hardware package idle states. 53\fB%pc2, %pc3, %pc6, %pc7\fP percentage residency in hardware package idle states.
49.fi 54.fi
50.PP 55.PP
51.SH EXAMPLE 56.SH EXAMPLE
@@ -53,25 +58,37 @@ Without any parameters, turbostat prints out counters ever 5 seconds.
53(override interval with "-i sec" option, or specify a command 58(override interval with "-i sec" option, or specify a command
54for turbostat to fork). 59for turbostat to fork).
55 60
56The first row of statistics reflect the average for the entire system. 61The first row of statistics is a summary for the entire system.
62Note that the summary is a weighted average.
57Subsequent rows show per-CPU statistics. 63Subsequent rows show per-CPU statistics.
58 64
59.nf 65.nf
60[root@x980]# ./turbostat 66[root@x980]# ./turbostat
61cr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6 67cor CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
62 0.04 1.62 3.38 0.11 0.00 99.85 0.00 95.07 68 0.60 1.63 3.38 2.91 0.00 96.49 0.00 76.64
63 0 0 0.04 1.62 3.38 0.06 0.00 99.90 0.00 95.07 69 0 0 0.59 1.62 3.38 4.51 0.00 94.90 0.00 76.64
64 0 6 0.02 1.62 3.38 0.08 0.00 99.90 0.00 95.07 70 0 6 1.13 1.64 3.38 3.97 0.00 94.90 0.00 76.64
65 1 2 0.10 1.62 3.38 0.29 0.00 99.61 0.00 95.07 71 1 2 0.08 1.62 3.38 0.07 0.00 99.85 0.00 76.64
66 1 8 0.11 1.62 3.38 0.28 0.00 99.61 0.00 95.07 72 1 8 0.03 1.62 3.38 0.12 0.00 99.85 0.00 76.64
67 2 4 0.01 1.62 3.38 0.01 0.00 99.98 0.00 95.07 73 2 4 0.01 1.62 3.38 0.06 0.00 99.93 0.00 76.64
68 2 10 0.01 1.61 3.38 0.02 0.00 99.98 0.00 95.07 74 2 10 0.04 1.62 3.38 0.02 0.00 99.93 0.00 76.64
69 8 1 0.07 1.62 3.38 0.15 0.00 99.78 0.00 95.07 75 8 1 2.85 1.62 3.38 11.71 0.00 85.44 0.00 76.64
70 8 7 0.03 1.62 3.38 0.19 0.00 99.78 0.00 95.07 76 8 7 1.98 1.62 3.38 12.58 0.00 85.44 0.00 76.64
71 9 3 0.01 1.62 3.38 0.02 0.00 99.98 0.00 95.07 77 9 3 0.36 1.62 3.38 0.71 0.00 98.93 0.00 76.64
72 9 9 0.01 1.62 3.38 0.02 0.00 99.98 0.00 95.07 78 9 9 0.09 1.62 3.38 0.98 0.00 98.93 0.00 76.64
73 10 5 0.01 1.62 3.38 0.13 0.00 99.86 0.00 95.07 79 10 5 0.03 1.62 3.38 0.09 0.00 99.87 0.00 76.64
74 10 11 0.08 1.62 3.38 0.05 0.00 99.86 0.00 95.07 80 10 11 0.07 1.62 3.38 0.06 0.00 99.87 0.00 76.64
81.fi
82.SH SUMMARY EXAMPLE
83The "-s" option prints the column headers just once,
84and then the one line system summary for each sample interval.
85
86.nf
87[root@x980]# ./turbostat -s
88 %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
89 0.61 1.89 3.38 5.95 0.00 93.44 0.00 66.33
90 0.52 1.62 3.38 6.83 0.00 92.65 0.00 61.11
91 0.62 1.92 3.38 5.47 0.00 93.91 0.00 67.31
75.fi 92.fi
76.SH VERBOSE EXAMPLE 93.SH VERBOSE EXAMPLE
77The "-v" option adds verbosity to the output: 94The "-v" option adds verbosity to the output:
@@ -101,33 +118,33 @@ until ^C while the other CPUs are mostly idle:
101 118
102.nf 119.nf
103[root@x980 lenb]# ./turbostat cat /dev/zero > /dev/null 120[root@x980 lenb]# ./turbostat cat /dev/zero > /dev/null
104 121^C
105^Ccr CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6 122cor CPU %c0 GHz TSC %c1 %c3 %c6 %pc3 %pc6
106 8.49 3.63 3.38 16.23 0.66 74.63 0.00 0.00 123 8.63 3.64 3.38 14.46 0.49 76.42 0.00 0.00
107 0 0 1.22 3.62 3.38 32.18 0.00 66.60 0.00 0.00 124 0 0 0.34 3.36 3.38 99.66 0.00 0.00 0.00 0.00
108 0 6 0.40 3.61 3.38 33.00 0.00 66.60 0.00 0.00 125 0 6 99.96 3.64 3.38 0.04 0.00 0.00 0.00 0.00
109 1 2 0.11 3.14 3.38 0.19 3.95 95.75 0.00 0.00 126 1 2 0.14 3.50 3.38 1.75 2.04 96.07 0.00 0.00
110 1 8 0.05 2.88 3.38 0.25 3.95 95.75 0.00 0.00 127 1 8 0.38 3.57 3.38 1.51 2.04 96.07 0.00 0.00
111 2 4 0.00 3.13 3.38 0.02 0.00 99.98 0.00 0.00 128 2 4 0.01 2.65 3.38 0.06 0.00 99.93 0.00 0.00
112 2 10 0.00 3.09 3.38 0.02 0.00 99.98 0.00 0.00 129 2 10 0.03 2.12 3.38 0.04 0.00 99.93 0.00 0.00
113 8 1 0.04 3.50 3.38 14.43 0.00 85.54 0.00 0.00 130 8 1 0.91 3.59 3.38 35.27 0.92 62.90 0.00 0.00
114 8 7 0.03 2.98 3.38 14.43 0.00 85.54 0.00 0.00 131 8 7 1.61 3.63 3.38 34.57 0.92 62.90 0.00 0.00
115 9 3 0.00 3.16 3.38 100.00 0.00 0.00 0.00 0.00 132 9 3 0.04 3.38 3.38 0.20 0.00 99.76 0.00 0.00
116 9 9 99.93 3.63 3.38 0.06 0.00 0.00 0.00 0.00 133 9 9 0.04 3.29 3.38 0.20 0.00 99.76 0.00 0.00
117 10 5 0.01 2.82 3.38 0.08 0.00 99.91 0.00 0.00 134 10 5 0.03 3.08 3.38 0.12 0.00 99.85 0.00 0.00
118 10 11 0.02 3.36 3.38 0.06 0.00 99.91 0.00 0.00 135 10 11 0.05 3.07 3.38 0.10 0.00 99.85 0.00 0.00
1196.950866 sec 1364.907015 sec
120 137
121.fi 138.fi
122Above the cycle soaker drives cpu9 up 3.6 Ghz turbo limit 139Above the cycle soaker drives cpu6 up 3.6 Ghz turbo limit
123while the other processors are generally in various states of idle. 140while the other processors are generally in various states of idle.
124 141
125Note that cpu3 is an HT sibling sharing core9 142Note that cpu0 is an HT sibling sharing core0
126with cpu9, and thus it is unable to get to an idle state 143with cpu6, and thus it is unable to get to an idle state
127deeper than c1 while cpu9 is busy. 144deeper than c1 while cpu6 is busy.
128 145
129Note that turbostat reports average GHz of 3.61, while 146Note that turbostat reports average GHz of 3.64, while
130the arithmetic average of the GHz column above is 3.24. 147the arithmetic average of the GHz column above is lower.
131This is a weighted average, where the weight is %c0. ie. it is the total number of 148This is a weighted average, where the weight is %c0. ie. it is the total number of
132un-halted cycles elapsed per time divided by the number of CPUs. 149un-halted cycles elapsed per time divided by the number of CPUs.
133.SH NOTES 150.SH NOTES
@@ -167,6 +184,6 @@ http://www.intel.com/products/processor/manuals/
167.SH "SEE ALSO" 184.SH "SEE ALSO"
168msr(4), vmstat(8) 185msr(4), vmstat(8)
169.PP 186.PP
170.SH AUTHORS 187.SH AUTHOR
171.nf 188.nf
172Written by Len Brown <len.brown@intel.com> 189Written by Len Brown <len.brown@intel.com>
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 310d3dd5e547..6436d54378c7 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -2,7 +2,7 @@
2 * turbostat -- show CPU frequency and C-state residency 2 * turbostat -- show CPU frequency and C-state residency
3 * on modern Intel turbo-capable processors. 3 * on modern Intel turbo-capable processors.
4 * 4 *
5 * Copyright (c) 2010, Intel Corporation. 5 * Copyright (c) 2012 Intel Corporation.
6 * Len Brown <len.brown@intel.com> 6 * Len Brown <len.brown@intel.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
@@ -49,6 +49,7 @@
49char *proc_stat = "/proc/stat"; 49char *proc_stat = "/proc/stat";
50unsigned int interval_sec = 5; /* set with -i interval_sec */ 50unsigned int interval_sec = 5; /* set with -i interval_sec */
51unsigned int verbose; /* set with -v */ 51unsigned int verbose; /* set with -v */
52unsigned int summary_only; /* set with -s */
52unsigned int skip_c0; 53unsigned int skip_c0;
53unsigned int skip_c1; 54unsigned int skip_c1;
54unsigned int do_nhm_cstates; 55unsigned int do_nhm_cstates;
@@ -129,14 +130,18 @@ void print_header(void)
129{ 130{
130 if (show_pkg) 131 if (show_pkg)
131 fprintf(stderr, "pk"); 132 fprintf(stderr, "pk");
133 if (show_pkg)
134 fprintf(stderr, " ");
132 if (show_core) 135 if (show_core)
133 fprintf(stderr, " cr"); 136 fprintf(stderr, "cor");
134 if (show_cpu) 137 if (show_cpu)
135 fprintf(stderr, " CPU"); 138 fprintf(stderr, " CPU");
139 if (show_pkg || show_core || show_cpu)
140 fprintf(stderr, " ");
136 if (do_nhm_cstates) 141 if (do_nhm_cstates)
137 fprintf(stderr, " %%c0 "); 142 fprintf(stderr, " %%c0");
138 if (has_aperf) 143 if (has_aperf)
139 fprintf(stderr, " GHz"); 144 fprintf(stderr, " GHz");
140 fprintf(stderr, " TSC"); 145 fprintf(stderr, " TSC");
141 if (do_nhm_cstates) 146 if (do_nhm_cstates)
142 fprintf(stderr, " %%c1"); 147 fprintf(stderr, " %%c1");
@@ -147,13 +152,13 @@ void print_header(void)
147 if (do_snb_cstates) 152 if (do_snb_cstates)
148 fprintf(stderr, " %%c7"); 153 fprintf(stderr, " %%c7");
149 if (do_snb_cstates) 154 if (do_snb_cstates)
150 fprintf(stderr, " %%pc2"); 155 fprintf(stderr, " %%pc2");
151 if (do_nhm_cstates) 156 if (do_nhm_cstates)
152 fprintf(stderr, " %%pc3"); 157 fprintf(stderr, " %%pc3");
153 if (do_nhm_cstates) 158 if (do_nhm_cstates)
154 fprintf(stderr, " %%pc6"); 159 fprintf(stderr, " %%pc6");
155 if (do_snb_cstates) 160 if (do_snb_cstates)
156 fprintf(stderr, " %%pc7"); 161 fprintf(stderr, " %%pc7");
157 if (extra_msr_offset) 162 if (extra_msr_offset)
158 fprintf(stderr, " MSR 0x%x ", extra_msr_offset); 163 fprintf(stderr, " MSR 0x%x ", extra_msr_offset);
159 164
@@ -187,6 +192,15 @@ void dump_list(struct counters *cnt)
187 dump_cnt(cnt); 192 dump_cnt(cnt);
188} 193}
189 194
195/*
196 * column formatting convention & formats
197 * package: "pk" 2 columns %2d
198 * core: "cor" 3 columns %3d
199 * CPU: "CPU" 3 columns %3d
200 * GHz: "GHz" 3 columns %3.2
201 * TSC: "TSC" 3 columns %3.2
202 * percentage " %pc3" %6.2
203 */
190void print_cnt(struct counters *p) 204void print_cnt(struct counters *p)
191{ 205{
192 double interval_float; 206 double interval_float;
@@ -196,39 +210,45 @@ void print_cnt(struct counters *p)
196 /* topology columns, print blanks on 1st (average) line */ 210 /* topology columns, print blanks on 1st (average) line */
197 if (p == cnt_average) { 211 if (p == cnt_average) {
198 if (show_pkg) 212 if (show_pkg)
213 fprintf(stderr, " ");
214 if (show_pkg && show_core)
199 fprintf(stderr, " "); 215 fprintf(stderr, " ");
200 if (show_core) 216 if (show_core)
201 fprintf(stderr, " "); 217 fprintf(stderr, " ");
202 if (show_cpu) 218 if (show_cpu)
203 fprintf(stderr, " "); 219 fprintf(stderr, " " " ");
204 } else { 220 } else {
205 if (show_pkg) 221 if (show_pkg)
206 fprintf(stderr, "%d", p->pkg); 222 fprintf(stderr, "%2d", p->pkg);
223 if (show_pkg && show_core)
224 fprintf(stderr, " ");
207 if (show_core) 225 if (show_core)
208 fprintf(stderr, "%4d", p->core); 226 fprintf(stderr, "%3d", p->core);
209 if (show_cpu) 227 if (show_cpu)
210 fprintf(stderr, "%4d", p->cpu); 228 fprintf(stderr, " %3d", p->cpu);
211 } 229 }
212 230
213 /* %c0 */ 231 /* %c0 */
214 if (do_nhm_cstates) { 232 if (do_nhm_cstates) {
233 if (show_pkg || show_core || show_cpu)
234 fprintf(stderr, " ");
215 if (!skip_c0) 235 if (!skip_c0)
216 fprintf(stderr, "%7.2f", 100.0 * p->mperf/p->tsc); 236 fprintf(stderr, "%6.2f", 100.0 * p->mperf/p->tsc);
217 else 237 else
218 fprintf(stderr, " ****"); 238 fprintf(stderr, " ****");
219 } 239 }
220 240
221 /* GHz */ 241 /* GHz */
222 if (has_aperf) { 242 if (has_aperf) {
223 if (!aperf_mperf_unstable) { 243 if (!aperf_mperf_unstable) {
224 fprintf(stderr, "%5.2f", 244 fprintf(stderr, " %3.2f",
225 1.0 * p->tsc / units * p->aperf / 245 1.0 * p->tsc / units * p->aperf /
226 p->mperf / interval_float); 246 p->mperf / interval_float);
227 } else { 247 } else {
228 if (p->aperf > p->tsc || p->mperf > p->tsc) { 248 if (p->aperf > p->tsc || p->mperf > p->tsc) {
229 fprintf(stderr, " ****"); 249 fprintf(stderr, " ***");
230 } else { 250 } else {
231 fprintf(stderr, "%4.1f*", 251 fprintf(stderr, "%3.1f*",
232 1.0 * p->tsc / 252 1.0 * p->tsc /
233 units * p->aperf / 253 units * p->aperf /
234 p->mperf / interval_float); 254 p->mperf / interval_float);
@@ -241,7 +261,7 @@ void print_cnt(struct counters *p)
241 261
242 if (do_nhm_cstates) { 262 if (do_nhm_cstates) {
243 if (!skip_c1) 263 if (!skip_c1)
244 fprintf(stderr, "%7.2f", 100.0 * p->c1/p->tsc); 264 fprintf(stderr, " %6.2f", 100.0 * p->c1/p->tsc);
245 else 265 else
246 fprintf(stderr, " ****"); 266 fprintf(stderr, " ****");
247 } 267 }
@@ -252,13 +272,13 @@ void print_cnt(struct counters *p)
252 if (do_snb_cstates) 272 if (do_snb_cstates)
253 fprintf(stderr, " %6.2f", 100.0 * p->c7/p->tsc); 273 fprintf(stderr, " %6.2f", 100.0 * p->c7/p->tsc);
254 if (do_snb_cstates) 274 if (do_snb_cstates)
255 fprintf(stderr, " %5.2f", 100.0 * p->pc2/p->tsc); 275 fprintf(stderr, " %6.2f", 100.0 * p->pc2/p->tsc);
256 if (do_nhm_cstates) 276 if (do_nhm_cstates)
257 fprintf(stderr, " %5.2f", 100.0 * p->pc3/p->tsc); 277 fprintf(stderr, " %6.2f", 100.0 * p->pc3/p->tsc);
258 if (do_nhm_cstates) 278 if (do_nhm_cstates)
259 fprintf(stderr, " %5.2f", 100.0 * p->pc6/p->tsc); 279 fprintf(stderr, " %6.2f", 100.0 * p->pc6/p->tsc);
260 if (do_snb_cstates) 280 if (do_snb_cstates)
261 fprintf(stderr, " %5.2f", 100.0 * p->pc7/p->tsc); 281 fprintf(stderr, " %6.2f", 100.0 * p->pc7/p->tsc);
262 if (extra_msr_offset) 282 if (extra_msr_offset)
263 fprintf(stderr, " 0x%016llx", p->extra_msr); 283 fprintf(stderr, " 0x%016llx", p->extra_msr);
264 putc('\n', stderr); 284 putc('\n', stderr);
@@ -267,12 +287,20 @@ void print_cnt(struct counters *p)
267void print_counters(struct counters *counters) 287void print_counters(struct counters *counters)
268{ 288{
269 struct counters *cnt; 289 struct counters *cnt;
290 static int printed;
270 291
271 print_header(); 292
293 if (!printed || !summary_only)
294 print_header();
272 295
273 if (num_cpus > 1) 296 if (num_cpus > 1)
274 print_cnt(cnt_average); 297 print_cnt(cnt_average);
275 298
299 printed = 1;
300
301 if (summary_only)
302 return;
303
276 for (cnt = counters; cnt != NULL; cnt = cnt->next) 304 for (cnt = counters; cnt != NULL; cnt = cnt->next)
277 print_cnt(cnt); 305 print_cnt(cnt);
278 306
@@ -557,7 +585,8 @@ void insert_counters(struct counters **list,
557 return; 585 return;
558 } 586 }
559 587
560 show_cpu = 1; /* there is more than one CPU */ 588 if (!summary_only)
589 show_cpu = 1; /* there is more than one CPU */
561 590
562 /* 591 /*
563 * insert on front of list. 592 * insert on front of list.
@@ -575,13 +604,15 @@ void insert_counters(struct counters **list,
575 604
576 while (prev->next && (prev->next->pkg < new->pkg)) { 605 while (prev->next && (prev->next->pkg < new->pkg)) {
577 prev = prev->next; 606 prev = prev->next;
578 show_pkg = 1; /* there is more than 1 package */ 607 if (!summary_only)
608 show_pkg = 1; /* there is more than 1 package */
579 } 609 }
580 610
581 while (prev->next && (prev->next->pkg == new->pkg) 611 while (prev->next && (prev->next->pkg == new->pkg)
582 && (prev->next->core < new->core)) { 612 && (prev->next->core < new->core)) {
583 prev = prev->next; 613 prev = prev->next;
584 show_core = 1; /* there is more than 1 core */ 614 if (!summary_only)
615 show_core = 1; /* there is more than 1 core */
585 } 616 }
586 617
587 while (prev->next && (prev->next->pkg == new->pkg) 618 while (prev->next && (prev->next->pkg == new->pkg)
@@ -1005,8 +1036,11 @@ void cmdline(int argc, char **argv)
1005 1036
1006 progname = argv[0]; 1037 progname = argv[0];
1007 1038
1008 while ((opt = getopt(argc, argv, "+vi:M:")) != -1) { 1039 while ((opt = getopt(argc, argv, "+svi:M:")) != -1) {
1009 switch (opt) { 1040 switch (opt) {
1041 case 's':
1042 summary_only++;
1043 break;
1010 case 'v': 1044 case 'v':
1011 verbose++; 1045 verbose++;
1012 break; 1046 break;