User: | Jiri Slaby |
Error type: | Resource Leak |
Error type description: | The code omits to put the resource to the system for reuse |
File location: | arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c |
Line in file: | 278 |
Project: | Linux Kernel |
Project version: | 2.6.28 |
Tools: |
Stanse
(1.2)
|
Entered: | 2011-11-07 22:40:13 UTC |
248 * to this function. 249 * Input: cpu number 250 * Return: Average CPU frequency in terms of max frequency (zero on error) 251 * 252 * We use IA32_MPERF and IA32_APERF MSRs to get the measured performance 253 * over a period of time, while CPU is in C0 state. 254 * IA32_MPERF counts at the rate of max advertised frequency 255 * IA32_APERF counts at the rate of actual CPU frequency 256 * Only IA32_APERF/IA32_MPERF ratio is architecturally defined and 257 * no meaning should be associated with absolute values of these MSRs. 258 */ 259static unsigned int get_measured_perf(struct cpufreq_policy *policy, 260 unsigned int cpu) 261{ 262 union { 263 struct { 264 u32 lo; 265 u32 hi; 266 } split; 267 u64 whole; 268 } aperf_cur, mperf_cur; 269 270 cpumask_t saved_mask; 271 unsigned int perf_percent; 272 unsigned int retval; 273 274 saved_mask = current->cpus_allowed; 275 set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu)); 276 if (get_cpu() != cpu) { 277 /* We were not able to run on requested processor */ 278 put_cpu(); 279 return 0; 280 } 281 282 rdmsr(MSR_IA32_APERF, aperf_cur.split.lo, aperf_cur.split.hi); 283 rdmsr(MSR_IA32_MPERF, mperf_cur.split.lo, mperf_cur.split.hi); 284 285 wrmsr(MSR_IA32_APERF, 0,0); 286 wrmsr(MSR_IA32_MPERF, 0,0); 287 288#ifdef __i386__