Skip to contentSkip to conversation

Race in cpufreq_add_dev()?

DISCUSSION Jeremy Fitzhardinge 2 participants 2 messages Jul 6, 2006 – Oct 3, 2006

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 11 lines · Jeremy Fitzhardinge

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;
	}
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