aboutsummaryrefslogtreecommitdiff
path: root/sys/x86
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2010-11-16 12:43:45 +0000
committerAndriy Gapon <avg@FreeBSD.org>2010-11-16 12:43:45 +0000
commit40934baa605543988ec92c34d30b9ee95f14fe5b (patch)
treee438aa2aaf4f35a6e29a72068a68b561c40f0a76 /sys/x86
parentf9e2e99d5d3ec4cb3f335e6c1152536600c6a0ca (diff)
downloadsrc-40934baa605543988ec92c34d30b9ee95f14fe5b.tar.gz
src-40934baa605543988ec92c34d30b9ee95f14fe5b.zip
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
Notes
Notes: svn path=/head/; revision=215398
Diffstat (limited to 'sys/x86')
-rw-r--r--sys/x86/cpufreq/hwpstate.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/sys/x86/cpufreq/hwpstate.c b/sys/x86/cpufreq/hwpstate.c
index 18659d7c1e3c..272792658e62 100644
--- a/sys/x86/cpufreq/hwpstate.c
+++ b/sys/x86/cpufreq/hwpstate.c
@@ -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);
}