Race in cpufreq_add_dev()?
cpufreq_add_dev contains the test:
#ifdef CONFIG_SMP
/* check whether a different CPU already registered this
* CPU because it is in the same boat. */
policy = cpufreq_cpu_get(cpu);
if (unlikely(policy)) {
cpufreq_cpu_put(policy);
cpufreq_debug_enable_ratelimit();
return 0;
}#endif
I don't see what prevents two CPUs from racing through here. Both could perform this test and find that there's no policy for the CPU, and then both will attempt to add it. Or is there something else which serializes multiple CPUs through this code?
J
Quoted 11 lines · Jeremy Fitzhardinge
cpufreq_add_devcontains the test:#ifdef CONFIG_SMP /* check whether a different CPU already registered this * CPU because it is in the same boat. */ policy = cpufreq_cpu_get(cpu); if (unlikely(policy)) { cpufreq_cpu_put(policy); cpufreq_debug_enable_ratelimit(); return 0; }
Quoted 6 lines
#endif
I don't see what prevents two CPUs from racing through here. Both could perform this test and find that there's no policy for the CPU, and then both will attempt to add it. Or is there something else which serializes multiple CPUs through this code?
AFAICS it is protected by sysdev_drivers_lock.
Dominik