Always call sched_bind(), even if on the CPU in question. It is wrong to

check if we're already on that cpu and skip the bind since the thread could
be migrated off in the meantime.

Suggested by:	jeff
Approved by:	re
This commit is contained in:
Nate Lawson 2007-08-20 06:28:26 +00:00
parent 2145b9d207
commit 62db376af3

View File

@ -227,7 +227,7 @@ cf_set_method(device_t dev, const struct cf_level *level, int priority)
const struct cf_setting *set; const struct cf_setting *set;
struct cf_saved_freq *saved_freq, *curr_freq; struct cf_saved_freq *saved_freq, *curr_freq;
struct pcpu *pc; struct pcpu *pc;
int cpu_id, error, i; int error, i;
sc = device_get_softc(dev); sc = device_get_softc(dev);
error = 0; error = 0;
@ -294,22 +294,17 @@ cf_set_method(device_t dev, const struct cf_level *level, int priority)
goto out; goto out;
} }
/* Bind to the target CPU before switching, if necessary. */ /* Bind to the target CPU before switching. */
cpu_id = PCPU_GET(cpuid);
pc = cpu_get_pcpu(set->dev); pc = cpu_get_pcpu(set->dev);
if (cpu_id != pc->pc_cpuid) { thread_lock(curthread);
thread_lock(curthread); sched_bind(curthread, pc->pc_cpuid);
sched_bind(curthread, pc->pc_cpuid); thread_unlock(curthread);
thread_unlock(curthread);
}
CF_DEBUG("setting abs freq %d on %s (cpu %d)\n", set->freq, CF_DEBUG("setting abs freq %d on %s (cpu %d)\n", set->freq,
device_get_nameunit(set->dev), PCPU_GET(cpuid)); device_get_nameunit(set->dev), PCPU_GET(cpuid));
error = CPUFREQ_DRV_SET(set->dev, set); error = CPUFREQ_DRV_SET(set->dev, set);
if (cpu_id != pc->pc_cpuid) { thread_lock(curthread);
thread_lock(curthread); sched_unbind(curthread);
sched_unbind(curthread); thread_unlock(curthread);
thread_unlock(curthread);
}
if (error) { if (error) {
goto out; goto out;
} }
@ -323,22 +318,17 @@ cf_set_method(device_t dev, const struct cf_level *level, int priority)
goto out; goto out;
} }
/* Bind to the target CPU before switching, if necessary. */ /* Bind to the target CPU before switching. */
cpu_id = PCPU_GET(cpuid);
pc = cpu_get_pcpu(set->dev); pc = cpu_get_pcpu(set->dev);
if (cpu_id != pc->pc_cpuid) { thread_lock(curthread);
thread_lock(curthread); sched_bind(curthread, pc->pc_cpuid);
sched_bind(curthread, pc->pc_cpuid); thread_unlock(curthread);
thread_unlock(curthread);
}
CF_DEBUG("setting rel freq %d on %s (cpu %d)\n", set->freq, CF_DEBUG("setting rel freq %d on %s (cpu %d)\n", set->freq,
device_get_nameunit(set->dev), PCPU_GET(cpuid)); device_get_nameunit(set->dev), PCPU_GET(cpuid));
error = CPUFREQ_DRV_SET(set->dev, set); error = CPUFREQ_DRV_SET(set->dev, set);
if (cpu_id != pc->pc_cpuid) { thread_lock(curthread);
thread_lock(curthread); sched_unbind(curthread);
sched_unbind(curthread); thread_unlock(curthread);
thread_unlock(curthread);
}
if (error) { if (error) {
/* XXX Back out any successful setting? */ /* XXX Back out any successful setting? */
goto out; goto out;