misc/104689: add support for limiting cpu frequency on adaptive mode
redchrom at gmail.com
redchrom at gmail.com
Sun Oct 22 15:10:21 PDT 2006
>Number: 104689
>Category: misc
>Synopsis: add support for limiting cpu frequency on adaptive mode
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sun Oct 22 22:10:14 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: Stepan Zastupov (RedChrom)
>Release: FreeBSD 7.0-CURRENT i386
>Organization:
ISPSystem
>Environment:
System: FreeBSD stepan.ispsystem.net 7.0-CURRENT FreeBSD 7.0-CURRENT #5: Fri Oct 20 11:51:51 IRKST 2006 root at stepan.ispsystem.net:/usr/obj/usr/src/sys/LILITH i386
>Description:
Adaptive mode really helps to prolong life of battery but with low idle it sets maximum frequency. I think limit maximum frequency on adaptive mode it's good idea. I know patch is very dirty but I hope you'll like my idea.
>How-To-Repeat:
Apply the patch and run powerd:
powerd -a maximum -b adaptive -m 558
Where 558 is maximum frequency on adaptive mode
>Fix:
--- powerd.c.diff begins here ---
--- powerd.c.orig Mon Oct 23 06:08:17 2006
+++ powerd.c Mon Oct 23 06:54:31 2006
@@ -370,7 +370,7 @@
struct pidfh *pfh = NULL;
const char *pidfile = NULL;
long idle, total;
- int curfreq, *freqs, i, *mwatts, numfreqs;
+ int curfreq, *freqs, i, *mwatts, numfreqs, maxfreq;
int ch, mode, mode_ac, mode_battery, mode_none;
uint64_t mjoules_used;
size_t len;
@@ -382,12 +382,13 @@
poll_ival = DEFAULT_POLL_INTERVAL;
mjoules_used = 0;
vflag = 0;
+ maxfreq = 0;
/* User must be root to control frequencies. */
if (geteuid() != 0)
errx(1, "must be root to run");
- while ((ch = getopt(argc, argv, "a:b:i:n:p:P:r:v")) != EOF)
+ while ((ch = getopt(argc, argv, "a:b:i:n:p:P:r:m:v")) != EOF)
switch (ch) {
case 'a':
parse_mode(optarg, &mode_ac, ch);
@@ -424,6 +425,9 @@
usage();
}
break;
+ case 'm':
+ maxfreq = atoi(optarg);
+ break;
case 'v':
vflag = 1;
break;
@@ -592,9 +596,19 @@
if (freqs[i] == curfreq)
break;
}
+
+ if (maxfreq == 0)
+ maxfreq = freqs[0];
+
if (idle < (total * cpu_running_mark) / 100 &&
- curfreq < freqs[0]) {
- i -= 2;
+ curfreq < maxfreq) {
+ /*
+ * I know, next three lines is dirty
+ */
+ i -= 1;
+ if (freqs[i] < maxfreq)
+ i -= 1;
+
if (i < 0)
i = 0;
if (vflag) {
--- powerd.c.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list