From owner-freebsd-acpi@FreeBSD.ORG Wed Mar 9 19:29:40 2005 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6B63116A4CE for ; Wed, 9 Mar 2005 19:29:40 +0000 (GMT) Received: from postal3.es.net (postal3.es.net [198.128.3.207]) by mx1.FreeBSD.org (Postfix) with ESMTP id 29EC943D77 for ; Wed, 9 Mar 2005 19:29:40 +0000 (GMT) (envelope-from oberman@es.net) Received: from ptavv.es.net ([198.128.4.29]) by postal3.es.net (Postal Node 3) with ESMTP (SSL) id IBA74465; Wed, 09 Mar 2005 11:29:38 -0800 Received: from ptavv (localhost [127.0.0.1]) by ptavv.es.net (Tachyon Server) with ESMTP id 23DCB5D07; Wed, 9 Mar 2005 11:29:38 -0800 (PST) X-Mailer: exmh version 2.7.0 06/18/2004 with nmh-1.0.4 To: nate@root.org Mime-Version: 1.0 Content-Type: multipart/mixed ; boundary="==_Exmh_-19024908990" Date: Wed, 09 Mar 2005 11:29:38 -0800 From: "Kevin Oberman" Message-Id: <20050309192938.23DCB5D07@ptavv.es.net> cc: acpi@freebsd.org Subject: Issues with powerd X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Mar 2005 19:29:40 -0000 This is a multipart MIME message. --==_Exmh_-19024908990 Content-Type: text/plain; charset=us-ascii 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@es.net Phone: +1 510 486-8634 --==_Exmh_-19024908990 Content-Type: text/plain ; name="powerd.c.diff"; charset=us-ascii Content-Description: powerd.c.diff Content-Disposition: attachment; filename="powerd.c.diff" --- powerd.c.orig Sat Feb 26 17:58:49 2005 +++ powerd.c Wed Mar 9 11:27:46 2005 @@ -43,7 +43,7 @@ #include #include -#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) { --==_Exmh_-19024908990--