Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[CPUFREQ][1/6] cpufreq: Add cpu number parameter to __cpufreq_driver_getavg()

Add a cpu parameter to __cpufreq_driver_getavg(). This is needed for software
cpufreq coordination where policy->cpu may not be same as the CPU on which we
want to getavg frequency.

A follow-on patch will use this parameter to getavg freq from all cpus
in policy->cpus.

Change since last patch. Fix the offline/online and suspend/resume
oops reported by Youquan Song <youquan.song@intel.com>

Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Dave Jones <davej@redhat.com>

authored by

venkatesh.pallipadi@intel.com and committed by
Dave Jones
bf0b90e3 8217e4f4

+12 -8
+3 -2
arch/x86/kernel/cpu/cpufreq/acpi-cpufreq.c
··· 256 256 * Only IA32_APERF/IA32_MPERF ratio is architecturally defined and 257 257 * no meaning should be associated with absolute values of these MSRs. 258 258 */ 259 - static unsigned int get_measured_perf(unsigned int cpu) 259 + static unsigned int get_measured_perf(struct cpufreq_policy *policy, 260 + unsigned int cpu) 260 261 { 261 262 union { 262 263 struct { ··· 327 326 328 327 #endif 329 328 330 - retval = per_cpu(drv_data, cpu)->max_freq * perf_percent / 100; 329 + retval = per_cpu(drv_data, policy->cpu)->max_freq * perf_percent / 100; 331 330 332 331 put_cpu(); 333 332 set_cpus_allowed_ptr(current, &saved_mask);
+3 -3
drivers/cpufreq/cpufreq.c
··· 1487 1487 } 1488 1488 EXPORT_SYMBOL_GPL(cpufreq_driver_target); 1489 1489 1490 - int __cpufreq_driver_getavg(struct cpufreq_policy *policy) 1490 + int __cpufreq_driver_getavg(struct cpufreq_policy *policy, unsigned int cpu) 1491 1491 { 1492 1492 int ret = 0; 1493 1493 ··· 1495 1495 if (!policy) 1496 1496 return -EINVAL; 1497 1497 1498 - if (cpu_online(policy->cpu) && cpufreq_driver->getavg) 1499 - ret = cpufreq_driver->getavg(policy->cpu); 1498 + if (cpu_online(cpu) && cpufreq_driver->getavg) 1499 + ret = cpufreq_driver->getavg(policy, cpu); 1500 1500 1501 1501 cpufreq_cpu_put(policy); 1502 1502 return ret;
+1 -1
drivers/cpufreq/cpufreq_ondemand.c
··· 415 415 if (load < (dbs_tuners_ins.up_threshold - 10)) { 416 416 unsigned int freq_next, freq_cur; 417 417 418 - freq_cur = __cpufreq_driver_getavg(policy); 418 + freq_cur = __cpufreq_driver_getavg(policy, policy->cpu); 419 419 if (!freq_cur) 420 420 freq_cur = policy->cur; 421 421
+5 -2
include/linux/cpufreq.h
··· 187 187 unsigned int relation); 188 188 189 189 190 - extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy); 190 + extern int __cpufreq_driver_getavg(struct cpufreq_policy *policy, 191 + unsigned int cpu); 191 192 192 193 int cpufreq_register_governor(struct cpufreq_governor *governor); 193 194 void cpufreq_unregister_governor(struct cpufreq_governor *governor); ··· 227 226 unsigned int (*get) (unsigned int cpu); 228 227 229 228 /* optional */ 230 - unsigned int (*getavg) (unsigned int cpu); 229 + unsigned int (*getavg) (struct cpufreq_policy *policy, 230 + unsigned int cpu); 231 + 231 232 int (*exit) (struct cpufreq_policy *policy); 232 233 int (*suspend) (struct cpufreq_policy *policy, pm_message_t pmsg); 233 234 int (*resume) (struct cpufreq_policy *policy);