diff options
author | Thomas Renninger <trenn@suse.de> | 2011-07-21 05:54:53 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2011-07-29 13:37:25 -0400 |
commit | 8fb2e440b223b966f74a04a48f6f71f288fa671b (patch) | |
tree | 3a9f2c19c039072d0b2641385bf0e6897bed2361 /tools/power | |
parent | 76b659a31df5174d71832b7882ef31b32e1f8d59 (diff) |
cpupower: Show Intel turbo ratio support via ./cpupower frequency-info
This adds the last piece missing from turbostat (if called with -v).
It shows on Intel machines supporting Turbo Boost how many cores
have to be active/idle to enter which boost mode (frequency).
Whether the HW really enters these boost modes can be verified via
./cpupower monitor.
Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: lenb@kernel.org
CC: linux@dominikbrodowski.net
CC: cpufreq@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'tools/power')
-rw-r--r-- | tools/power/cpupower/utils/cpufreq-info.c | 54 | ||||
-rw-r--r-- | tools/power/cpupower/utils/helpers/cpuid.c | 29 | ||||
-rw-r--r-- | tools/power/cpupower/utils/helpers/helpers.h | 13 | ||||
-rw-r--r-- | tools/power/cpupower/utils/helpers/msr.c | 16 |
4 files changed, 95 insertions, 17 deletions
diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpupower/utils/cpufreq-info.c index 8628644188cf..5a1d25f056b3 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c | |||
@@ -165,26 +165,56 @@ static int get_boost_mode(unsigned int cpu) | |||
165 | printf(_(" Supported: %s\n"), support ? _("yes") : _("no")); | 165 | printf(_(" Supported: %s\n"), support ? _("yes") : _("no")); |
166 | printf(_(" Active: %s\n"), active ? _("yes") : _("no")); | 166 | printf(_(" Active: %s\n"), active ? _("yes") : _("no")); |
167 | 167 | ||
168 | /* ToDo: Only works for AMD for now... */ | ||
169 | |||
170 | if (cpupower_cpu_info.vendor == X86_VENDOR_AMD && | 168 | if (cpupower_cpu_info.vendor == X86_VENDOR_AMD && |
171 | cpupower_cpu_info.family >= 0x10) { | 169 | cpupower_cpu_info.family >= 0x10) { |
172 | ret = decode_pstates(cpu, cpupower_cpu_info.family, b_states, | 170 | ret = decode_pstates(cpu, cpupower_cpu_info.family, b_states, |
173 | pstates, &pstate_no); | 171 | pstates, &pstate_no); |
174 | if (ret) | 172 | if (ret) |
175 | return ret; | 173 | return ret; |
176 | } else | ||
177 | return 0; | ||
178 | 174 | ||
179 | printf(_(" Boost States: %d\n"), b_states); | 175 | printf(_(" Boost States: %d\n"), b_states); |
180 | printf(_(" Total States: %d\n"), pstate_no); | 176 | printf(_(" Total States: %d\n"), pstate_no); |
181 | for (i = 0; i < pstate_no; i++) { | 177 | for (i = 0; i < pstate_no; i++) { |
182 | if (i < b_states) | 178 | if (i < b_states) |
183 | printf(_(" Pstate-Pb%d: %luMHz (boost state)\n"), | 179 | printf(_(" Pstate-Pb%d: %luMHz (boost state)" |
184 | i, pstates[i]); | 180 | "\n"), i, pstates[i]); |
181 | else | ||
182 | printf(_(" Pstate-P%d: %luMHz\n"), | ||
183 | i - b_states, pstates[i]); | ||
184 | } | ||
185 | } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_HAS_TURBO_RATIO) { | ||
186 | double bclk; | ||
187 | unsigned long long intel_turbo_ratio = 0; | ||
188 | unsigned int ratio; | ||
189 | |||
190 | /* Any way to autodetect this ? */ | ||
191 | if (cpupower_cpu_info.caps & CPUPOWER_CAP_IS_SNB) | ||
192 | bclk = 100.00; | ||
185 | else | 193 | else |
186 | printf(_(" Pstate-P%d: %luMHz\n"), | 194 | bclk = 133.33; |
187 | i - b_states, pstates[i]); | 195 | intel_turbo_ratio = msr_intel_get_turbo_ratio(cpu); |
196 | dprint (" Ratio: 0x%llx - bclk: %f\n", | ||
197 | intel_turbo_ratio, bclk); | ||
198 | |||
199 | ratio = (intel_turbo_ratio >> 24) & 0xFF; | ||
200 | if (ratio) | ||
201 | printf(_(" %.0f MHz max turbo 4 active cores\n"), | ||
202 | ratio * bclk); | ||
203 | |||
204 | ratio = (intel_turbo_ratio >> 16) & 0xFF; | ||
205 | if (ratio) | ||
206 | printf(_(" %.0f MHz max turbo 3 active cores\n"), | ||
207 | ratio * bclk); | ||
208 | |||
209 | ratio = (intel_turbo_ratio >> 8) & 0xFF; | ||
210 | if (ratio) | ||
211 | printf(_(" %.0f MHz max turbo 2 active cores\n"), | ||
212 | ratio * bclk); | ||
213 | |||
214 | ratio = (intel_turbo_ratio >> 0) & 0xFF; | ||
215 | if (ratio) | ||
216 | printf(_(" %.0f MHz max turbo 1 active cores\n"), | ||
217 | ratio * bclk); | ||
188 | } | 218 | } |
189 | return 0; | 219 | return 0; |
190 | } | 220 | } |
diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c index 944b2c1659d8..a97f091fcf2b 100644 --- a/tools/power/cpupower/utils/helpers/cpuid.c +++ b/tools/power/cpupower/utils/helpers/cpuid.c | |||
@@ -130,10 +130,37 @@ out: | |||
130 | cpu_info->caps |= CPUPOWER_CAP_AMD_CBP; | 130 | cpu_info->caps |= CPUPOWER_CAP_AMD_CBP; |
131 | } | 131 | } |
132 | 132 | ||
133 | /* Intel's perf-bias MSR support */ | ||
134 | if (cpu_info->vendor == X86_VENDOR_INTEL) { | 133 | if (cpu_info->vendor == X86_VENDOR_INTEL) { |
134 | /* Intel's perf-bias MSR support */ | ||
135 | if (cpuid_level >= 6 && (cpuid_ecx(6) & (1 << 3))) | 135 | if (cpuid_level >= 6 && (cpuid_ecx(6) & (1 << 3))) |
136 | cpu_info->caps |= CPUPOWER_CAP_PERF_BIAS; | 136 | cpu_info->caps |= CPUPOWER_CAP_PERF_BIAS; |
137 | |||
138 | /* Intel's Turbo Ratio Limit support */ | ||
139 | if (cpu_info->family == 6) { | ||
140 | switch (cpu_info->model) { | ||
141 | case 0x1A: /* Core i7, Xeon 5500 series | ||
142 | * Bloomfield, Gainstown NHM-EP | ||
143 | */ | ||
144 | case 0x1E: /* Core i7 and i5 Processor | ||
145 | * Clarksfield, Lynnfield, Jasper Forest | ||
146 | */ | ||
147 | case 0x1F: /* Core i7 and i5 Processor - Nehalem */ | ||
148 | case 0x25: /* Westmere Client | ||
149 | * Clarkdale, Arrandale | ||
150 | */ | ||
151 | case 0x2C: /* Westmere EP - Gulftown */ | ||
152 | cpu_info->caps |= CPUPOWER_CAP_HAS_TURBO_RATIO; | ||
153 | case 0x2A: /* SNB */ | ||
154 | case 0x2D: /* SNB Xeon */ | ||
155 | cpu_info->caps |= CPUPOWER_CAP_HAS_TURBO_RATIO; | ||
156 | cpu_info->caps |= CPUPOWER_CAP_IS_SNB; | ||
157 | break; | ||
158 | case 0x2E: /* Nehalem-EX Xeon - Beckton */ | ||
159 | case 0x2F: /* Westmere-EX Xeon - Eagleton */ | ||
160 | default: | ||
161 | break; | ||
162 | } | ||
163 | } | ||
137 | } | 164 | } |
138 | 165 | ||
139 | /* printf("ID: %u - Extid: 0x%x - Caps: 0x%llx\n", | 166 | /* printf("ID: %u - Extid: 0x%x - Caps: 0x%llx\n", |
diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h index 048f065925c9..9125a551ac1d 100644 --- a/tools/power/cpupower/utils/helpers/helpers.h +++ b/tools/power/cpupower/utils/helpers/helpers.h | |||
@@ -52,10 +52,12 @@ extern int be_verbose; | |||
52 | enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, | 52 | enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, |
53 | X86_VENDOR_AMD, X86_VENDOR_MAX}; | 53 | X86_VENDOR_AMD, X86_VENDOR_MAX}; |
54 | 54 | ||
55 | #define CPUPOWER_CAP_INV_TSC 0x00000001 | 55 | #define CPUPOWER_CAP_INV_TSC 0x00000001 |
56 | #define CPUPOWER_CAP_APERF 0x00000002 | 56 | #define CPUPOWER_CAP_APERF 0x00000002 |
57 | #define CPUPOWER_CAP_AMD_CBP 0x00000004 | 57 | #define CPUPOWER_CAP_AMD_CBP 0x00000004 |
58 | #define CPUPOWER_CAP_PERF_BIAS 0x00000008 | 58 | #define CPUPOWER_CAP_PERF_BIAS 0x00000008 |
59 | #define CPUPOWER_CAP_HAS_TURBO_RATIO 0x00000010 | ||
60 | #define CPUPOWER_CAP_IS_SNB 0x00000011 | ||
59 | 61 | ||
60 | #define MAX_HW_PSTATES 10 | 62 | #define MAX_HW_PSTATES 10 |
61 | 63 | ||
@@ -111,6 +113,7 @@ extern int write_msr(int cpu, unsigned int idx, unsigned long long val); | |||
111 | 113 | ||
112 | extern int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val); | 114 | extern int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val); |
113 | extern int msr_intel_get_perf_bias(unsigned int cpu); | 115 | extern int msr_intel_get_perf_bias(unsigned int cpu); |
116 | extern unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu); | ||
114 | 117 | ||
115 | extern int msr_intel_has_boost_support(unsigned int cpu); | 118 | extern int msr_intel_has_boost_support(unsigned int cpu); |
116 | extern int msr_intel_boost_is_active(unsigned int cpu); | 119 | extern int msr_intel_boost_is_active(unsigned int cpu); |
@@ -157,6 +160,8 @@ static inline int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val) | |||
157 | { return -1; }; | 160 | { return -1; }; |
158 | static inline int msr_intel_get_perf_bias(unsigned int cpu) | 161 | static inline int msr_intel_get_perf_bias(unsigned int cpu) |
159 | { return -1; }; | 162 | { return -1; }; |
163 | static inline unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu) | ||
164 | { return 0; }; | ||
160 | 165 | ||
161 | static inline int msr_intel_has_boost_support(unsigned int cpu) | 166 | static inline int msr_intel_has_boost_support(unsigned int cpu) |
162 | { return -1; }; | 167 | { return -1; }; |
diff --git a/tools/power/cpupower/utils/helpers/msr.c b/tools/power/cpupower/utils/helpers/msr.c index 93d48bd56e57..7869ca64dfd3 100644 --- a/tools/power/cpupower/utils/helpers/msr.c +++ b/tools/power/cpupower/utils/helpers/msr.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #define MSR_IA32_PERF_STATUS 0x198 | 11 | #define MSR_IA32_PERF_STATUS 0x198 |
12 | #define MSR_IA32_MISC_ENABLES 0x1a0 | 12 | #define MSR_IA32_MISC_ENABLES 0x1a0 |
13 | #define MSR_IA32_ENERGY_PERF_BIAS 0x1b0 | 13 | #define MSR_IA32_ENERGY_PERF_BIAS 0x1b0 |
14 | #define MSR_NEHALEM_TURBO_RATIO_LIMIT 0x1ad | ||
14 | 15 | ||
15 | /* | 16 | /* |
16 | * read_msr | 17 | * read_msr |
@@ -79,6 +80,7 @@ int msr_intel_has_boost_support(unsigned int cpu) | |||
79 | ret = read_msr(cpu, MSR_IA32_MISC_ENABLES, &misc_enables); | 80 | ret = read_msr(cpu, MSR_IA32_MISC_ENABLES, &misc_enables); |
80 | if (ret) | 81 | if (ret) |
81 | return ret; | 82 | return ret; |
83 | |||
82 | return (misc_enables >> 38) & 0x1; | 84 | return (misc_enables >> 38) & 0x1; |
83 | } | 85 | } |
84 | 86 | ||
@@ -119,4 +121,18 @@ int msr_intel_set_perf_bias(unsigned int cpu, unsigned int val) | |||
119 | return ret; | 121 | return ret; |
120 | return 0; | 122 | return 0; |
121 | } | 123 | } |
124 | |||
125 | unsigned long long msr_intel_get_turbo_ratio(unsigned int cpu) | ||
126 | { | ||
127 | unsigned long long val; | ||
128 | int ret; | ||
129 | |||
130 | if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_HAS_TURBO_RATIO)) | ||
131 | return -1; | ||
132 | |||
133 | ret = read_msr(cpu, MSR_NEHALEM_TURBO_RATIO_LIMIT, &val); | ||
134 | if (ret) | ||
135 | return ret; | ||
136 | return val; | ||
137 | } | ||
122 | #endif | 138 | #endif |