aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2015-02-10 01:56:38 -0500
committerLen Brown <len.brown@intel.com>2015-02-10 01:56:38 -0500
commitd8af6f5f0fca7c5271539dab0d75942ccf09d65c (patch)
tree19f4dfcdd8c8c173c66ee02c4aecd053819bf433 /tools
parentee7e38e3d8805ba6471bddd088fae92ce5ab1ef5 (diff)
tools/power turbostat: update parameters, documentation
Long format options added, though the short ones should still work. eg. the new "--Counter 0x10" is the same as the old "-C 0x10" Note this Incompatibility: Old: -v displayed verbose debug output New: -v and --version simpaly display version Additional parameters: -d and --debug display verbose debug output -h and --help display a help message Updated turbosat.8 man page accordingly. Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/x86/turbostat/turbostat.868
-rw-r--r--tools/power/x86/turbostat/turbostat.c155
2 files changed, 136 insertions, 87 deletions
diff --git a/tools/power/x86/turbostat/turbostat.8 b/tools/power/x86/turbostat/turbostat.8
index 9b950699e63d..feea7ad9500b 100644
--- a/tools/power/x86/turbostat/turbostat.8
+++ b/tools/power/x86/turbostat/turbostat.8
@@ -9,7 +9,7 @@ turbostat \- Report processor frequency and idle statistics
9.br 9.br
10.B turbostat 10.B turbostat
11.RB [ Options ] 11.RB [ Options ]
12.RB [ "\-i interval_sec" ] 12.RB [ "\--interval seconds" ]
13.SH DESCRIPTION 13.SH DESCRIPTION
14\fBturbostat \fP reports processor topology, frequency, 14\fBturbostat \fP reports processor topology, frequency,
15idle power-state statistics, temperature and power on X86 processors. 15idle power-state statistics, temperature and power on X86 processors.
@@ -18,31 +18,41 @@ The first method is to supply a
18\fBcommand\fP, which is forked and statistics are printed 18\fBcommand\fP, which is forked and statistics are printed
19upon its completion. 19upon its completion.
20The second method is to omit the command, 20The second method is to omit the command,
21and turbodstat will print statistics every 5 seconds. 21and turbostat displays statistics every 5 seconds.
22The 5-second interval can changed using the -i option. 22The 5-second interval can be changed using the --interval option.
23 23
24Some information is not availalbe on older processors. 24Some information is not available on older processors.
25.SS Options 25.SS Options
26The \fB-p\fP option limits output to the 1st thread in 1st core of each package. 26\fB--Counter MSR#\fP shows the delta of the specified 64-bit MSR counter.
27.PP 27.PP
28The \fB-P\fP option limits output to the 1st thread in each Package. 28\fB--counter MSR#\fP shows the delta of the specified 32-bit MSR counter.
29.PP 29.PP
30The \fB-S\fP option limits output to a 1-line System Summary for each interval. 30\fB--Dump\fP displays the raw counter values.
31.PP 31.PP
32The \fB-v\fP option increases verbosity. 32\fB--debug\fP displays additional system configuration information. Invoking this parameter
33more than once may also enable internal turbostat debug information.
33.PP 34.PP
34The \fB-c MSR#\fP option includes the delta of the specified 32-bit MSR counter. 35\fB--interval seconds\fP overrides the default 5-second measurement interval.
35.PP 36.PP
36The \fB-C MSR#\fP option includes the delta of the specified 64-bit MSR counter. 37\fB--help\fP displays usage for the most common parameters.
37.PP 38.PP
38The \fB-m MSR#\fP option includes the the specified 32-bit MSR value. 39\fB--Joules\fP displays energy in Joules, rather than dividing Joules by time to print power in Watts.
39.PP 40.PP
40The \fB-M MSR#\fP option includes the the specified 64-bit MSR value. 41\fB--MSR MSR#\fP shows the specified 64-bit MSR value.
41.PP 42.PP
42The \fB-i interval_sec\fP option prints statistics every \fiinterval_sec\fP seconds. 43\fB--msr MSR#\fP shows the specified 32-bit MSR value.
43The default is 5 seconds.
44.PP 44.PP
45The \fBcommand\fP parameter forks \fBcommand\fP and upon its exit, 45\fB--Package\fP limits output to the system summary plus the 1st thread in each Package.
46.PP
47\fB--processor\fP limits output to the system summary plus the 1st thread in each processor of each package. Ie. it skips hyper-threaded siblings.
48.PP
49\fB--Summary\fP limits output to a 1-line System Summary for each interval.
50.PP
51\fB--TCC temperature\fP sets the Thermal Control Circuit temperature for systems which do not export that value. This is used for making sense of the Digital Thermal Sensor outputs, as they return degrees Celsius below the TCC activation temperature.
52.PP
53\fB--version\fP displays the version.
54.PP
55The \fBcommand\fP parameter forks \fBcommand\fP, and upon its exit,
46displays the statistics gathered since it was forked. 56displays the statistics gathered since it was forked.
47.PP 57.PP
48.SH FIELD DESCRIPTIONS 58.SH FIELD DESCRIPTIONS
@@ -52,7 +62,7 @@ displays the statistics gathered since it was forked.
52\fBCPU\fP Linux CPU (logical processor) number. 62\fBCPU\fP Linux CPU (logical processor) number.
53Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology. 63Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading Technology.
54\fBAVG_MHz\fP number of cycles executed divided by time elapsed. 64\fBAVG_MHz\fP number of cycles executed divided by time elapsed.
55\fB%Buzy\fP percent of the interval that the CPU retired instructions, aka. % of time in "C0" state. 65\fB%Busy\fP percent of the interval that the CPU retired instructions, aka. % of time in "C0" state.
56\fBBzy_MHz\fP average clock rate while the CPU was busy (in "c0" state). 66\fBBzy_MHz\fP average clock rate while the CPU was busy (in "c0" state).
57\fBTSC_MHz\fP average MHz that the TSC ran during the entire interval. 67\fBTSC_MHz\fP average MHz that the TSC ran during the entire interval.
58\fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states. 68\fBCPU%c1, CPU%c3, CPU%c6, CPU%c7\fP show the percentage residency in hardware core idle states.
@@ -68,7 +78,7 @@ Note that multiple CPUs per core indicate support for Intel(R) Hyper-Threading T
68.fi 78.fi
69.PP 79.PP
70.SH EXAMPLE 80.SH EXAMPLE
71Without any parameters, turbostat prints out counters ever 5 seconds. 81Without any parameters, turbostat displays statistics ever 5 seconds.
72(override interval with "-i sec" option, or specify a command 82(override interval with "-i sec" option, or specify a command
73for turbostat to fork). 83for turbostat to fork).
74 84
@@ -91,19 +101,19 @@ Subsequent rows show per-CPU statistics.
91 3 3 3 0.20 1596 3492 0 0.44 0.00 99.37 0.00 23 101 3 3 3 0.20 1596 3492 0 0.44 0.00 99.37 0.00 23
92 3 7 5 0.31 1596 3492 0 0.33 102 3 7 5 0.31 1596 3492 0 0.33
93.fi 103.fi
94.SH VERBOSE EXAMPLE 104.SH DEBUG EXAMPLE
95The "-v" option adds verbosity to the output: 105The "--debug" option prints additional system information before measurements:
96 106
97.nf 107.nf
98[root@ivy]# turbostat -v 108turbostat version 4.0 10-Feb, 2015 - Len Brown <lenb@kernel.org>
99turbostat v3.0 November 23, 2012 - Len Brown <lenb@kernel.org>
100CPUID(0): GenuineIntel 13 CPUID levels; family:model:stepping 0x6:3a:9 (6:58:9) 109CPUID(0): GenuineIntel 13 CPUID levels; family:model:stepping 0x6:3a:9 (6:58:9)
101CPUID(6): APERF, DTS, PTM, EPB 110CPUID(6): APERF, DTS, PTM, EPB
102RAPL: 851 sec. Joule Counter Range 111RAPL: 851 sec. Joule Counter Range, at 77 Watts
103cpu0: MSR_NHM_PLATFORM_INFO: 0x81010f0012300 112cpu0: MSR_NHM_PLATFORM_INFO: 0x81010f0012300
10416 * 100 = 1600 MHz max efficiency 11316 * 100 = 1600 MHz max efficiency
10535 * 100 = 3500 MHz TSC frequency 11435 * 100 = 3500 MHz TSC frequency
106cpu0: MSR_NHM_SNB_PKG_CST_CFG_CTL: 0x1e008402 (UNdemote-C3, UNdemote-C1, demote-C3, demote-C1, locked: pkg-cstate-limit=2: pc6-noret) 115cpu0: MSR_IA32_POWER_CTL: 0x0014005d (C1E auto-promotion: DISabled)
116cpu0: MSR_NHM_SNB_PKG_CST_CFG_CTL: 0x1e008402 (UNdemote-C3, UNdemote-C1, demote-C3, demote-C1, locked: pkg-cstate-limit=2: pc6n)
107cpu0: MSR_NHM_TURBO_RATIO_LIMIT: 0x25262727 117cpu0: MSR_NHM_TURBO_RATIO_LIMIT: 0x25262727
10837 * 100 = 3700 MHz max turbo 4 active cores 11837 * 100 = 3700 MHz max turbo 4 active cores
10938 * 100 = 3800 MHz max turbo 3 active cores 11938 * 100 = 3800 MHz max turbo 3 active cores
@@ -112,9 +122,9 @@ cpu0: MSR_NHM_TURBO_RATIO_LIMIT: 0x25262727
112cpu0: MSR_IA32_ENERGY_PERF_BIAS: 0x00000006 (balanced) 122cpu0: MSR_IA32_ENERGY_PERF_BIAS: 0x00000006 (balanced)
113cpu0: MSR_RAPL_POWER_UNIT: 0x000a1003 (0.125000 Watts, 0.000015 Joules, 0.000977 sec.) 123cpu0: MSR_RAPL_POWER_UNIT: 0x000a1003 (0.125000 Watts, 0.000015 Joules, 0.000977 sec.)
114cpu0: MSR_PKG_POWER_INFO: 0x01e00268 (77 W TDP, RAPL 60 - 0 W, 0.000000 sec.) 124cpu0: MSR_PKG_POWER_INFO: 0x01e00268 (77 W TDP, RAPL 60 - 0 W, 0.000000 sec.)
115cpu0: MSR_PKG_POWER_LIMIT: 0x830000148268 (UNlocked) 125cpu0: MSR_PKG_POWER_LIMIT: 0x30000148268 (UNlocked)
116cpu0: PKG Limit #1: ENabled (77.000000 Watts, 1.000000 sec, clamp DISabled) 126cpu0: PKG Limit #1: ENabled (77.000000 Watts, 1.000000 sec, clamp DISabled)
117cpu0: PKG Limit #2: ENabled (96.000000 Watts, 0.000977* sec, clamp DISabled) 127cpu0: PKG Limit #2: DISabled (96.000000 Watts, 0.000977* sec, clamp DISabled)
118cpu0: MSR_PP0_POLICY: 0 128cpu0: MSR_PP0_POLICY: 0
119cpu0: MSR_PP0_POWER_LIMIT: 0x00000000 (UNlocked) 129cpu0: MSR_PP0_POWER_LIMIT: 0x00000000 (UNlocked)
120cpu0: Cores Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled) 130cpu0: Cores Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled)
@@ -123,9 +133,9 @@ cpu0: MSR_PP1_POWER_LIMIT: 0x00000000 (UNlocked)
123cpu0: GFX Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled) 133cpu0: GFX Limit: DISabled (0.000000 Watts, 0.000977 sec, clamp DISabled)
124cpu0: MSR_IA32_TEMPERATURE_TARGET: 0x00691400 (105 C) 134cpu0: MSR_IA32_TEMPERATURE_TARGET: 0x00691400 (105 C)
125cpu0: MSR_IA32_PACKAGE_THERM_STATUS: 0x884e0000 (27 C) 135cpu0: MSR_IA32_PACKAGE_THERM_STATUS: 0x884e0000 (27 C)
126cpu0: MSR_IA32_THERM_STATUS: 0x88560000 (19 C +/- 1) 136cpu0: MSR_IA32_THERM_STATUS: 0x88580000 (17 C +/- 1)
127cpu1: MSR_IA32_THERM_STATUS: 0x88560000 (19 C +/- 1) 137cpu1: MSR_IA32_THERM_STATUS: 0x885a0000 (15 C +/- 1)
128cpu2: MSR_IA32_THERM_STATUS: 0x88540000 (21 C +/- 1) 138cpu2: MSR_IA32_THERM_STATUS: 0x88570000 (18 C +/- 1)
129cpu3: MSR_IA32_THERM_STATUS: 0x884e0000 (27 C +/- 1) 139cpu3: MSR_IA32_THERM_STATUS: 0x884e0000 (27 C +/- 1)
130 ... 140 ...
131.fi 141.fi
@@ -195,7 +205,7 @@ in those kernels.
195 205
196AVG_MHz = APERF_delta/measurement_interval. This is the actual 206AVG_MHz = APERF_delta/measurement_interval. This is the actual
197number of elapsed cycles divided by the entire sample interval -- 207number of elapsed cycles divided by the entire sample interval --
198including idle time. Note that this calculation is resiliant 208including idle time. Note that this calculation is resilient
199to systems lacking a non-stop TSC. 209to systems lacking a non-stop TSC.
200 210
201TSC_MHz = TSC_delta/measurement_interval. 211TSC_MHz = TSC_delta/measurement_interval.
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index ba8846b309f7..3f5a9af34f47 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -33,6 +33,7 @@
33#include <signal.h> 33#include <signal.h>
34#include <sys/time.h> 34#include <sys/time.h>
35#include <stdlib.h> 35#include <stdlib.h>
36#include <getopt.h>
36#include <dirent.h> 37#include <dirent.h>
37#include <string.h> 38#include <string.h>
38#include <ctype.h> 39#include <ctype.h>
@@ -42,13 +43,11 @@
42#include <errno.h> 43#include <errno.h>
43 44
44char *proc_stat = "/proc/stat"; 45char *proc_stat = "/proc/stat";
45unsigned int interval_sec = 5; /* set with -i interval_sec */ 46unsigned int interval_sec = 5;
46unsigned int verbose; /* set with -v */ 47unsigned int debug;
47unsigned int rapl_verbose; /* set with -R */ 48unsigned int rapl_joules;
48unsigned int rapl_joules; /* set with -J */ 49unsigned int summary_only;
49unsigned int thermal_verbose; /* set with -T */ 50unsigned int dump_only;
50unsigned int summary_only; /* set with -S */
51unsigned int dump_only; /* set with -s */
52unsigned int skip_c0; 51unsigned int skip_c0;
53unsigned int skip_c1; 52unsigned int skip_c1;
54unsigned int do_nhm_cstates; 53unsigned int do_nhm_cstates;
@@ -727,7 +726,7 @@ delta_thread(struct thread_data *new, struct thread_data *old,
727 } 726 }
728 727
729 if (old->mperf == 0) { 728 if (old->mperf == 0) {
730 if (verbose > 1) fprintf(stderr, "cpu%d MPERF 0!\n", old->cpu_id); 729 if (debug > 1) fprintf(stderr, "cpu%d MPERF 0!\n", old->cpu_id);
731 old->mperf = 1; /* divide by 0 protection */ 730 old->mperf = 1; /* divide by 0 protection */
732 } 731 }
733 732
@@ -1847,7 +1846,7 @@ void rapl_probe(unsigned int family, unsigned int model)
1847 tdp = get_tdp(model); 1846 tdp = get_tdp(model);
1848 1847
1849 rapl_joule_counter_range = 0xFFFFFFFF * rapl_energy_units / tdp; 1848 rapl_joule_counter_range = 0xFFFFFFFF * rapl_energy_units / tdp;
1850 if (verbose) 1849 if (debug)
1851 fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range, at %.0f Watts\n", rapl_joule_counter_range, tdp); 1850 fprintf(stderr, "RAPL: %.0f sec. Joule Counter Range, at %.0f Watts\n", rapl_joule_counter_range, tdp);
1852 1851
1853 return; 1852 return;
@@ -1972,7 +1971,7 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
1972 if (get_msr(cpu, MSR_RAPL_POWER_UNIT, &msr)) 1971 if (get_msr(cpu, MSR_RAPL_POWER_UNIT, &msr))
1973 return -1; 1972 return -1;
1974 1973
1975 if (verbose) { 1974 if (debug) {
1976 fprintf(stderr, "cpu%d: MSR_RAPL_POWER_UNIT: 0x%08llx " 1975 fprintf(stderr, "cpu%d: MSR_RAPL_POWER_UNIT: 0x%08llx "
1977 "(%f Watts, %f Joules, %f sec.)\n", cpu, msr, 1976 "(%f Watts, %f Joules, %f sec.)\n", cpu, msr,
1978 rapl_power_units, rapl_energy_units, rapl_time_units); 1977 rapl_power_units, rapl_energy_units, rapl_time_units);
@@ -2029,7 +2028,7 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
2029 print_power_limit_msr(cpu, msr, "DRAM Limit"); 2028 print_power_limit_msr(cpu, msr, "DRAM Limit");
2030 } 2029 }
2031 if (do_rapl & RAPL_CORE_POLICY) { 2030 if (do_rapl & RAPL_CORE_POLICY) {
2032 if (verbose) { 2031 if (debug) {
2033 if (get_msr(cpu, MSR_PP0_POLICY, &msr)) 2032 if (get_msr(cpu, MSR_PP0_POLICY, &msr))
2034 return -7; 2033 return -7;
2035 2034
@@ -2037,7 +2036,7 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
2037 } 2036 }
2038 } 2037 }
2039 if (do_rapl & RAPL_CORES) { 2038 if (do_rapl & RAPL_CORES) {
2040 if (verbose) { 2039 if (debug) {
2041 2040
2042 if (get_msr(cpu, MSR_PP0_POWER_LIMIT, &msr)) 2041 if (get_msr(cpu, MSR_PP0_POWER_LIMIT, &msr))
2043 return -9; 2042 return -9;
@@ -2047,7 +2046,7 @@ int print_rapl(struct thread_data *t, struct core_data *c, struct pkg_data *p)
2047 } 2046 }
2048 } 2047 }
2049 if (do_rapl & RAPL_GFX) { 2048 if (do_rapl & RAPL_GFX) {
2050 if (verbose) { 2049 if (debug) {
2051 if (get_msr(cpu, MSR_PP1_POLICY, &msr)) 2050 if (get_msr(cpu, MSR_PP1_POLICY, &msr))
2052 return -8; 2051 return -8;
2053 2052
@@ -2208,7 +2207,7 @@ int set_temperature_target(struct thread_data *t, struct core_data *c, struct pk
2208 2207
2209 target_c_local = (msr >> 16) & 0xFF; 2208 target_c_local = (msr >> 16) & 0xFF;
2210 2209
2211 if (verbose) 2210 if (debug)
2212 fprintf(stderr, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n", 2211 fprintf(stderr, "cpu%d: MSR_IA32_TEMPERATURE_TARGET: 0x%08llx (%d C)\n",
2213 cpu, msr, target_c_local); 2212 cpu, msr, target_c_local);
2214 2213
@@ -2238,7 +2237,7 @@ void check_cpuid()
2238 if (ebx == 0x756e6547 && edx == 0x49656e69 && ecx == 0x6c65746e) 2237 if (ebx == 0x756e6547 && edx == 0x49656e69 && ecx == 0x6c65746e)
2239 genuine_intel = 1; 2238 genuine_intel = 1;
2240 2239
2241 if (verbose) 2240 if (debug)
2242 fprintf(stderr, "CPUID(0): %.4s%.4s%.4s ", 2241 fprintf(stderr, "CPUID(0): %.4s%.4s%.4s ",
2243 (char *)&ebx, (char *)&edx, (char *)&ecx); 2242 (char *)&ebx, (char *)&edx, (char *)&ecx);
2244 2243
@@ -2249,7 +2248,7 @@ void check_cpuid()
2249 if (family == 6 || family == 0xf) 2248 if (family == 6 || family == 0xf)
2250 model += ((fms >> 16) & 0xf) << 4; 2249 model += ((fms >> 16) & 0xf) << 4;
2251 2250
2252 if (verbose) 2251 if (debug)
2253 fprintf(stderr, "%d CPUID levels; family:model:stepping 0x%x:%x:%x (%d:%d:%d)\n", 2252 fprintf(stderr, "%d CPUID levels; family:model:stepping 0x%x:%x:%x (%d:%d:%d)\n",
2254 max_level, family, model, stepping, family, model, stepping); 2253 max_level, family, model, stepping, family, model, stepping);
2255 2254
@@ -2285,7 +2284,7 @@ void check_cpuid()
2285 do_ptm = eax & (1 << 6); 2284 do_ptm = eax & (1 << 6);
2286 has_epb = ecx & (1 << 3); 2285 has_epb = ecx & (1 << 3);
2287 2286
2288 if (verbose) 2287 if (debug)
2289 fprintf(stderr, "CPUID(6): %sAPERF, %sDTS, %sPTM, %sEPB\n", 2288 fprintf(stderr, "CPUID(6): %sAPERF, %sDTS, %sPTM, %sEPB\n",
2290 has_aperf ? "" : "No ", 2289 has_aperf ? "" : "No ",
2291 do_dts ? "" : "No ", 2290 do_dts ? "" : "No ",
@@ -2311,10 +2310,25 @@ void check_cpuid()
2311} 2310}
2312 2311
2313 2312
2314void usage() 2313void help()
2315{ 2314{
2316 errx(1, "%s: [-v][-R][-T][-p|-P|-S][-c MSR#][-C MSR#][-m MSR#][-M MSR#][-i interval_sec | command ...]\n", 2315 fprintf(stderr,
2317 progname); 2316 "Usage: turbostat [OPTIONS][(--interval seconds) | COMMAND ...]\n"
2317 "\n"
2318 "Turbostat forks the specified COMMAND and prints statistics\n"
2319 "when COMMAND completes.\n"
2320 "If no COMMAND is specified, turbostat wakes every 5-seconds\n"
2321 "to print statistics, until interrupted.\n"
2322 "--debug run in \"debug\" mode\n"
2323 "--interval sec Override default 5-second measurement interval\n"
2324 "--help print this help message\n"
2325 "--counter msr print 32-bit counter at address \"msr\"\n"
2326 "--Counter msr print 64-bit Counter at address \"msr\"\n"
2327 "--msr msr print 32-bit value at address \"msr\"\n"
2328 "--MSR msr print 64-bit Value at address \"msr\"\n"
2329 "--version print version information\n"
2330 "\n"
2331 "For more help, run \"man turbostat\"\n");
2318} 2332}
2319 2333
2320 2334
@@ -2353,7 +2367,7 @@ void topology_probe()
2353 if (!summary_only && topo.num_cpus > 1) 2367 if (!summary_only && topo.num_cpus > 1)
2354 show_cpu = 1; 2368 show_cpu = 1;
2355 2369
2356 if (verbose > 1) 2370 if (debug > 1)
2357 fprintf(stderr, "num_cpus %d max_cpu_num %d\n", topo.num_cpus, topo.max_cpu_num); 2371 fprintf(stderr, "num_cpus %d max_cpu_num %d\n", topo.num_cpus, topo.max_cpu_num);
2358 2372
2359 cpus = calloc(1, (topo.max_cpu_num + 1) * sizeof(struct cpu_topology)); 2373 cpus = calloc(1, (topo.max_cpu_num + 1) * sizeof(struct cpu_topology));
@@ -2388,7 +2402,7 @@ void topology_probe()
2388 int siblings; 2402 int siblings;
2389 2403
2390 if (cpu_is_not_present(i)) { 2404 if (cpu_is_not_present(i)) {
2391 if (verbose > 1) 2405 if (debug > 1)
2392 fprintf(stderr, "cpu%d NOT PRESENT\n", i); 2406 fprintf(stderr, "cpu%d NOT PRESENT\n", i);
2393 continue; 2407 continue;
2394 } 2408 }
@@ -2403,26 +2417,26 @@ void topology_probe()
2403 siblings = get_num_ht_siblings(i); 2417 siblings = get_num_ht_siblings(i);
2404 if (siblings > max_siblings) 2418 if (siblings > max_siblings)
2405 max_siblings = siblings; 2419 max_siblings = siblings;
2406 if (verbose > 1) 2420 if (debug > 1)
2407 fprintf(stderr, "cpu %d pkg %d core %d\n", 2421 fprintf(stderr, "cpu %d pkg %d core %d\n",
2408 i, cpus[i].physical_package_id, cpus[i].core_id); 2422 i, cpus[i].physical_package_id, cpus[i].core_id);
2409 } 2423 }
2410 topo.num_cores_per_pkg = max_core_id + 1; 2424 topo.num_cores_per_pkg = max_core_id + 1;
2411 if (verbose > 1) 2425 if (debug > 1)
2412 fprintf(stderr, "max_core_id %d, sizing for %d cores per package\n", 2426 fprintf(stderr, "max_core_id %d, sizing for %d cores per package\n",
2413 max_core_id, topo.num_cores_per_pkg); 2427 max_core_id, topo.num_cores_per_pkg);
2414 if (!summary_only && topo.num_cores_per_pkg > 1) 2428 if (!summary_only && topo.num_cores_per_pkg > 1)
2415 show_core = 1; 2429 show_core = 1;
2416 2430
2417 topo.num_packages = max_package_id + 1; 2431 topo.num_packages = max_package_id + 1;
2418 if (verbose > 1) 2432 if (debug > 1)
2419 fprintf(stderr, "max_package_id %d, sizing for %d packages\n", 2433 fprintf(stderr, "max_package_id %d, sizing for %d packages\n",
2420 max_package_id, topo.num_packages); 2434 max_package_id, topo.num_packages);
2421 if (!summary_only && topo.num_packages > 1) 2435 if (!summary_only && topo.num_packages > 1)
2422 show_pkg = 1; 2436 show_pkg = 1;
2423 2437
2424 topo.num_threads_per_core = max_siblings; 2438 topo.num_threads_per_core = max_siblings;
2425 if (verbose > 1) 2439 if (debug > 1)
2426 fprintf(stderr, "max_siblings %d\n", max_siblings); 2440 fprintf(stderr, "max_siblings %d\n", max_siblings);
2427 2441
2428 free(cpus); 2442 free(cpus);
@@ -2537,21 +2551,21 @@ void turbostat_init()
2537 2551
2538 setup_all_buffers(); 2552 setup_all_buffers();
2539 2553
2540 if (verbose) 2554 if (debug)
2541 print_verbose_header(); 2555 print_verbose_header();
2542 2556
2543 if (verbose) 2557 if (debug)
2544 for_all_cpus(print_epb, ODD_COUNTERS); 2558 for_all_cpus(print_epb, ODD_COUNTERS);
2545 2559
2546 if (verbose) 2560 if (debug)
2547 for_all_cpus(print_perf_limit, ODD_COUNTERS); 2561 for_all_cpus(print_perf_limit, ODD_COUNTERS);
2548 2562
2549 if (verbose) 2563 if (debug)
2550 for_all_cpus(print_rapl, ODD_COUNTERS); 2564 for_all_cpus(print_rapl, ODD_COUNTERS);
2551 2565
2552 for_all_cpus(set_temperature_target, ODD_COUNTERS); 2566 for_all_cpus(set_temperature_target, ODD_COUNTERS);
2553 2567
2554 if (verbose) 2568 if (debug)
2555 for_all_cpus(print_thermal, ODD_COUNTERS); 2569 for_all_cpus(print_thermal, ODD_COUNTERS);
2556} 2570}
2557 2571
@@ -2616,56 +2630,82 @@ int get_and_dump_counters(void)
2616 return status; 2630 return status;
2617} 2631}
2618 2632
2633void print_version() {
2634 fprintf(stderr, "turbostat version 4.0 10-Feb, 2015"
2635 " - Len Brown <lenb@kernel.org>\n");
2636}
2637
2619void cmdline(int argc, char **argv) 2638void cmdline(int argc, char **argv)
2620{ 2639{
2621 int opt; 2640 int opt;
2641 int option_index = 0;
2642 static struct option long_options[] = {
2643 {"Counter", required_argument, 0, 'C'},
2644 {"counter", required_argument, 0, 'c'},
2645 {"Dump", no_argument, 0, 'D'},
2646 {"debug", no_argument, 0, 'd'},
2647 {"interval", required_argument, 0, 'i'},
2648 {"help", no_argument, 0, 'h'},
2649 {"Joules", no_argument, 0, 'J'},
2650 {"MSR", required_argument, 0, 'M'},
2651 {"msr", required_argument, 0, 'm'},
2652 {"Package", no_argument, 0, 'p'},
2653 {"processor", no_argument, 0, 'p'},
2654 {"Summary", no_argument, 0, 'S'},
2655 {"TCC", required_argument, 0, 'T'},
2656 {"version", no_argument, 0, 'v' },
2657 {0, 0, 0, 0 }
2658 };
2622 2659
2623 progname = argv[0]; 2660 progname = argv[0];
2624 2661
2625 while ((opt = getopt(argc, argv, "+pPsSvi:c:C:m:M:RJT:")) != -1) { 2662 while ((opt = getopt_long_only(argc, argv, "C:c:Ddhi:JM:m:PpST:v",
2663 long_options, &option_index)) != -1) {
2626 switch (opt) { 2664 switch (opt) {
2627 case 'p': 2665 case 'C':
2628 show_core_only++; 2666 sscanf(optarg, "%x", &extra_delta_offset64);
2629 break; 2667 break;
2630 case 'P': 2668 case 'c':
2631 show_pkg_only++; 2669 sscanf(optarg, "%x", &extra_delta_offset32);
2632 break; 2670 break;
2633 case 's': 2671 case 'D':
2634 dump_only++; 2672 dump_only++;
2635 break; 2673 break;
2636 case 'S': 2674 case 'd':
2637 summary_only++; 2675 debug++;
2638 break;
2639 case 'v':
2640 verbose++;
2641 break; 2676 break;
2677 case 'h':
2678 default:
2679 help();
2680 exit(1);
2642 case 'i': 2681 case 'i':
2643 interval_sec = atoi(optarg); 2682 interval_sec = atoi(optarg);
2644 break; 2683 break;
2645 case 'c': 2684 case 'J':
2646 sscanf(optarg, "%x", &extra_delta_offset32); 2685 rapl_joules++;
2647 break; 2686 break;
2648 case 'C': 2687 case 'M':
2649 sscanf(optarg, "%x", &extra_delta_offset64); 2688 sscanf(optarg, "%x", &extra_msr_offset64);
2650 break; 2689 break;
2651 case 'm': 2690 case 'm':
2652 sscanf(optarg, "%x", &extra_msr_offset32); 2691 sscanf(optarg, "%x", &extra_msr_offset32);
2653 break; 2692 break;
2654 case 'M': 2693 case 'P':
2655 sscanf(optarg, "%x", &extra_msr_offset64); 2694 show_pkg_only++;
2695 break;
2696 case 'p':
2697 show_core_only++;
2656 break; 2698 break;
2657 case 'R': 2699 case 'S':
2658 rapl_verbose++; 2700 summary_only++;
2659 break; 2701 break;
2660 case 'T': 2702 case 'T':
2661 tcc_activation_temp_override = atoi(optarg); 2703 tcc_activation_temp_override = atoi(optarg);
2662 break; 2704 break;
2663 case 'J': 2705 case 'v':
2664 rapl_joules++; 2706 print_version();
2707 exit(0);
2665 break; 2708 break;
2666
2667 default:
2668 usage();
2669 } 2709 }
2670 } 2710 }
2671} 2711}
@@ -2674,9 +2714,8 @@ int main(int argc, char **argv)
2674{ 2714{
2675 cmdline(argc, argv); 2715 cmdline(argc, argv);
2676 2716
2677 if (verbose) 2717 if (debug)
2678 fprintf(stderr, "turbostat v3.10 9-Feb, 2015" 2718 print_version();
2679 " - Len Brown <lenb@kernel.org>\n");
2680 2719
2681 turbostat_init(); 2720 turbostat_init();
2682 2721