Issues with powerd

Kevin Oberman oberman at es.net
Wed Mar 9 11:29:40 PST 2005


I have finally had a little time to play with powerd and I didn't find
adaptive mode worked too well for me on my T30 running a Gnome desktop.

The effect of running powerd was to move the freq in a rapid sawtooth
dropping quickly to 150 MHz and them jumping back to 1800 and
repeating. If the CPU was busy, the low point of the sawtooth would be
elevated to 300or 600, but the basic pattern was constant oscillation.

I looked at the source and decided that two things were wrong.

1. Dropping to half of the initial CPU speed was to a good choice. The
drop is speed was too quick and it resulted in reducing the number of
CPU performance levels to a small number instead of the 15 that should
be available.

2. When the CPU got busier, jumping all the way to full speed was
excessive and would always result in the sawtooth oscillation.

I modified powerd to increase or decrease cpufreq in single steps instead
of jumping (in either direction) and lowered DEFAULT_ACTIVE_PERCENT to
75. This results in a system that wanders between 150 and 450 when idle
and climbs to full speed when under load.

I suspect this is sub-optimal, but I think it's a lot better then the
current operation. I will try to spend some time tweaking the algorithm
a bit to see what makes things run best (for my personal idea of "best".

Ideally, I'd like to see it stay constant an an idle or constantly
loaded system and I suspect that I will need to add hysteresis to get
there. 

Attached are my patch to powerd.c.
-- 
R. Kevin Oberman, Network Engineer
Energy Sciences Network (ESnet)
Ernest O. Lawrence Berkeley National Laboratory (Berkeley Lab)
E-mail: oberman at es.net			Phone: +1 510 486-8634

-------------- next part --------------
--- powerd.c.orig	Sat Feb 26 17:58:49 2005
+++ powerd.c	Wed Mar  9 11:27:46 2005
@@ -43,7 +43,7 @@
 #include <sys/sysctl.h>
 #include <sys/resource.h>
 
-#define DEFAULT_ACTIVE_PERCENT	80
+#define DEFAULT_ACTIVE_PERCENT	75
 #define DEFAULT_IDLE_PERCENT	90
 #define DEFAULT_POLL_INTERVAL	500
 
@@ -379,24 +379,28 @@
 
 		/*
 		 * If we're idle less than the active mark, jump the CPU to
-		 * its fastest speed if we're not there yet.  If we're idle
+		 * the next faster speed if we're not there yet.  If we're idle
 		 * more than the idle mark, drop down to the first setting
 		 * that is half the current speed (exponential backoff).
 		 */
 		if (idle < (total * cpu_running_mark) / 100 &&
 		    curfreq < freqs[0]) {
+		  for (i = (numfreqs - 1); i >= 0; i--) {
+		    if (freqs[i] > curfreq)
+		      break;
+		  }
 			if (vflag) {
 				printf("idle time < %d%%, increasing clock"
 				    " speed from %d MHz to %d MHz\n",
-				    cpu_running_mark, curfreq, freqs[0]);
+				    cpu_running_mark, curfreq, freqs[i]);
 			}
-			if (set_freq(freqs[0]))
+			if (set_freq(freqs[i]))
 				err(1, "error setting CPU frequency %d",
-				    freqs[0]);
+				    freqs[i]);
 		} else if (idle > (total * cpu_idle_mark) / 100 &&
 		    curfreq > freqs[numfreqs - 1]) {
 			for (i = 0; i < numfreqs - 1; i++) {
-				if (freqs[i] <= curfreq / 2)
+				if (freqs[i] < curfreq)
 					break;
 			}
 			if (vflag) {


More information about the freebsd-acpi mailing list