Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Aug 2005 20:14:42 +0900
From:      Hajimu UMEMOTO <ume@FreeBSD.org>
To:        Bruno Ducrot <bruno@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/usr.sbin/powerd powerd.c
Message-ID:  <ygemzn7zivx.wl%ume@mahoroba.org>
In-Reply-To: <200508240752.j7O7qxep016309@repoman.freebsd.org>
References:  <200508240752.j7O7qxep016309@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

>>>>> On Wed, 24 Aug 2005 07:52:59 +0000 (UTC)
>>>>> Bruno Ducrot <bruno@FreeBSD.org> said:

bruno>   Modified files:
bruno>     usr.sbin/powerd      powerd.c 
bruno>   Log:
bruno>   Change the default adaptive algorithm for phk's one.  Thanks to phk
bruno>   and Kevin Oberman for this work.

It feels too lazy for my laptop.  One freq level for decreasing and
two freq level for incresing is comfortable to me.  Is there any
chance to add an option for changing step for increasing or decreasing
CPU freq level?

Index: usr.sbin/powerd/powerd.8
diff -u usr.sbin/powerd/powerd.8.orig usr.sbin/powerd/powerd.8
--- usr.sbin/powerd/powerd.8.orig	Thu Jul 21 18:35:33 2005
+++ usr.sbin/powerd/powerd.8	Wed Aug 24 20:02:59 2005
@@ -37,6 +37,7 @@
 .Op Fl i percent
 .Op Fl n mode
 .Op Fl p ival
+.Op Fl s step
 .Op Fl r percent
 .Op Fl v
 .Sh DESCRIPTION
@@ -82,6 +83,10 @@
 Specifies a different polling interval (in milliseconds) for AC line state
 and system idle levels.
 The default is 500 ms.
+.It Fl s Ar step
+Specifies the step for increasing or decreasing the CPU frequency
+level.
+The default is 1.
 .It Fl r Ar percent
 Specifies the CPU idle percent level where
 adaptive
Index: usr.sbin/powerd/powerd.c
diff -u -p usr.sbin/powerd/powerd.c.orig usr.sbin/powerd/powerd.c
--- usr.sbin/powerd/powerd.c.orig	Wed Aug 24 19:38:34 2005
+++ usr.sbin/powerd/powerd.c	Wed Aug 24 20:04:48 2005
@@ -244,7 +244,7 @@ usage(void)
 {
 
 	fprintf(stderr,
-"usage: powerd [-v] [-a mode] [-b mode] [-i %%] [-n mode] [-p ival] [-r %%]\n");
+"usage: powerd [-v] [-a mode] [-b mode] [-i %%] [-n mode] [-p ival] [-r %%] [-s step]\n");
 	exit(1);
 }
 
@@ -253,7 +253,7 @@ main(int argc, char * argv[])
 {
 	long idle, total;
 	int curfreq, *freqs, i, *mwatts, numfreqs;
-	int ch, mode_ac, mode_battery, mode_none, acline, mode, vflag;
+	int ch, mode_ac, mode_battery, mode_none, acline, mode, vflag, step;
 	uint64_t mjoules_used;
 	size_t len;
 
@@ -264,9 +264,10 @@ main(int argc, char * argv[])
 	poll_ival = DEFAULT_POLL_INTERVAL;
 	mjoules_used = 0;
 	vflag = 0;
+	step = 1;
 	apm_fd = -1;
 
-	while ((ch = getopt(argc, argv, "a:b:i:n:p:r:v")) != EOF)
+	while ((ch = getopt(argc, argv, "a:b:i:n:p:r:s:v")) != EOF)
 		switch (ch) {
 		case 'a':
 			parse_mode(optarg, &mode_ac, ch);
@@ -300,6 +301,13 @@ main(int argc, char * argv[])
 				usage();
 			}
 			break;
+		case 's':
+			step = atoi(optarg);
+			if (step < 1) {
+				warnx("%d is not a valid step", step);
+				usage();
+			}
+			break;
 		case 'v':
 			vflag = 1;
 			break;
@@ -427,7 +435,7 @@ main(int argc, char * argv[])
 		}
 		if (idle < (total * cpu_running_mark) / 100 &&
 		    curfreq < freqs[0]) {
-			i -= 2;
+			i -= step * 2;
 			if (i < 0)
 				i = 0;
 			if (vflag) {
@@ -440,7 +448,9 @@ main(int argc, char * argv[])
 				    freqs[i]);
 		} else if (idle > (total * cpu_idle_mark) / 100 &&
 		    curfreq > freqs[numfreqs - 1]) {
-			i++;
+			i += step;
+			if (i >= numfreqs)
+				i = numfreqs - 1;
 			if (vflag) {
 				printf("idle time > %d%%, decreasing clock"
 				    " speed from %d MHz to %d MHz\n",

Sincerely,

--
Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan
ume@mahoroba.org  ume@{,jp.}FreeBSD.org
http://www.imasy.org/~ume/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ygemzn7zivx.wl%ume>