diff options
author | bruno <bruno@FreeBSD.org> | 2005-08-24 07:52:59 +0000 |
---|---|---|
committer | bruno <bruno@FreeBSD.org> | 2005-08-24 07:52:59 +0000 |
commit | 16471328fb54a086bc75ad54c11df18d276ea257 (patch) | |
tree | 44872255ddc45472a127eb83cae38ccbd041f0d4 /usr.sbin/powerd | |
parent | 813fe6cce62d257dba7802a1a78285f91cc9df85 (diff) | |
download | FreeBSD-src-16471328fb54a086bc75ad54c11df18d276ea257.zip FreeBSD-src-16471328fb54a086bc75ad54c11df18d276ea257.tar.gz |
Change the default adaptive algorithm for phk's one. Thanks to phk
and Kevin Oberman for this work.
Submitted by: Kevin Oberman
Reviewed by: njl
Approved by: njl
Diffstat (limited to 'usr.sbin/powerd')
-rw-r--r-- | usr.sbin/powerd/powerd.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/usr.sbin/powerd/powerd.c b/usr.sbin/powerd/powerd.c index 7c8ab40..80547d5 100644 --- a/usr.sbin/powerd/powerd.c +++ b/usr.sbin/powerd/powerd.c @@ -425,27 +425,29 @@ main(int argc, char * argv[]) err(1, "read_usage_times"); /* - * 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 - * more than the idle mark, drop down to the first setting - * that is half the current speed (exponential backoff). + * If we're idle less than the active mark, bump up two levels. + * If we're idle more than the idle mark, drop down one level. */ + for (i = 0; i < numfreqs - 1; i++) { + if (freqs[i] == curfreq) + break; + } if (idle < (total * cpu_running_mark) / 100 && curfreq < freqs[0]) { + i -= 2; + if (i < 0) + i = 0; 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) - break; - } + i++; if (vflag) { printf("idle time > %d%%, decreasing clock" " speed from %d MHz to %d MHz\n", |