svn commit: r215398 - head/sys/x86/cpufreq

Andriy Gapon avg at FreeBSD.org
Tue Nov 16 12:43:46 UTC 2010


Author: avg
Date: Tue Nov 16 12:43:45 2010
New Revision: 215398
URL: http://svn.freebsd.org/changeset/base/215398

Log:
  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

Modified:
  head/sys/x86/cpufreq/hwpstate.c

Modified: head/sys/x86/cpufreq/hwpstate.c
==============================================================================
--- head/sys/x86/cpufreq/hwpstate.c	Tue Nov 16 12:30:47 2010	(r215397)
+++ head/sys/x86/cpufreq/hwpstate.c	Tue Nov 16 12:43:45 2010	(r215398)
@@ -157,7 +157,6 @@ DRIVER_MODULE(hwpstate, cpu, hwpstate_dr
 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 p
 	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 p
 			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);
 }
 


More information about the svn-src-head mailing list