hwpstate: use CPU_FOREACH when binding to all available processors
Also, add a comment mentioning _PSD - on some systems it's enough to put one logical CPU into a particular P-state to make other CPUs in the same domain to enter that P-state. Also, call sched_unbind() after the loop - sched_bind() automatically rebinds from previous CPU to a new one, and the new arrangement of code is safer against early loop exit. Plus one minor style nit. MFC after: 10 days
This commit is contained in:
parent
f9e2e99d5d
commit
40934baa60
@ -157,7 +157,6 @@ DRIVER_MODULE(hwpstate, cpu, hwpstate_driver, hwpstate_devclass, 0, 0);
|
||||
static int
|
||||
hwpstate_goto_pstate(device_t dev, int pstate)
|
||||
{
|
||||
struct pcpu *pc;
|
||||
int i;
|
||||
uint64_t msr;
|
||||
int j;
|
||||
@ -171,18 +170,15 @@ hwpstate_goto_pstate(device_t dev, int pstate)
|
||||
if(limit > id)
|
||||
id = limit;
|
||||
|
||||
error = 0;
|
||||
/*
|
||||
* We are going to the same Px-state on all cpus.
|
||||
* Probably should take _PSD into account.
|
||||
*/
|
||||
for (i = 0; i < mp_ncpus; i++) {
|
||||
/* Find each cpu. */
|
||||
pc = pcpu_find(i);
|
||||
if (pc == NULL)
|
||||
return (ENXIO);
|
||||
thread_lock(curthread);
|
||||
error = 0;
|
||||
CPU_FOREACH(i) {
|
||||
/* Bind to each cpu. */
|
||||
sched_bind(curthread, pc->pc_cpuid);
|
||||
thread_lock(curthread);
|
||||
sched_bind(curthread, i);
|
||||
thread_unlock(curthread);
|
||||
HWPSTATE_DEBUG(dev, "setting P%d-state on cpu%d\n",
|
||||
id, PCPU_GET(cpuid));
|
||||
@ -204,10 +200,10 @@ hwpstate_goto_pstate(device_t dev, int pstate)
|
||||
HWPSTATE_DEBUG(dev, "error: loop is not enough.\n");
|
||||
error = ENXIO;
|
||||
}
|
||||
thread_lock(curthread);
|
||||
sched_unbind(curthread);
|
||||
thread_unlock(curthread);
|
||||
}
|
||||
thread_lock(curthread);
|
||||
sched_unbind(curthread);
|
||||
thread_unlock(curthread);
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user