Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jul 2013 20:12:12 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        acpi@freebsd.org
Cc:        wblock@freebsd.org
Subject:   Hyper mode for powerd
Message-ID:  <alpine.BSF.2.00.1307041955110.10280@wonkity.com>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Attached is a proposed patch for -head that adds a "hyper" mode to 
powerd.  Instead of slewing like the adaptive modes, this mode drops all 
the way to the lowest frequency when the system is idle, and jumps all 
the way to the highest frequency when there is any load.

Subjectively, it seems more responsive for desktop use than hiadaptive 
mode.  That's hard to benchmark.  Power usage is another question. 
This mode might use less power than the adaptive modes, but that's also 
difficult to benchmark.

Comments welcome.
[-- Attachment #2 --]
Index: usr.sbin/powerd/powerd.c
===================================================================
--- usr.sbin/powerd/powerd.c	(revision 252713)
+++ usr.sbin/powerd/powerd.c	(working copy)
@@ -63,6 +63,7 @@
 	MODE_MIN,
 	MODE_ADAPTIVE,
 	MODE_HIADAPTIVE,
+	MODE_HYPER,
 	MODE_MAX,
 } modes_t;
 
@@ -419,6 +420,8 @@
 		*mode = MODE_ADAPTIVE;
 	else if (strcmp(arg, "hiadaptive") == 0 || strcmp(arg, "hadp") == 0)
 		*mode = MODE_HIADAPTIVE;
+	else if (strcmp(arg, "hyper") == 0 || strcmp(arg, "hype") == 0)
+		*mode = MODE_HYPER;
 	else
 		errx(1, "bad option: -%c %s", (char)ch, optarg);
 }
@@ -593,11 +596,11 @@
 	if (acline_status > SRC_UNKNOWN)
 		errx(1, "invalid AC line status %d", acline_status);
 	if ((acline_status == SRC_AC &&
-	    (mode_ac == MODE_ADAPTIVE || mode_ac == MODE_HIADAPTIVE)) ||
+	    (mode_ac == MODE_ADAPTIVE || mode_ac == MODE_HIADAPTIVE || mode_ac == MODE_HYPER)) ||
 	    (acline_status == SRC_BATTERY &&
-	    (mode_battery == MODE_ADAPTIVE || mode_battery == MODE_HIADAPTIVE)) ||
+	    (mode_battery == MODE_ADAPTIVE || mode_battery == MODE_HIADAPTIVE || mode_battery == MODE_HYPER)) ||
 	    (acline_status == SRC_UNKNOWN &&
-	    (mode_none == MODE_ADAPTIVE || mode_none == MODE_HIADAPTIVE))) {
+	    (mode_none == MODE_ADAPTIVE || mode_none == MODE_HIADAPTIVE || mode_none == MODE_HYPER))) {
 		/* Read the current frequency. */
 		len = sizeof(curfreq);
 		if (sysctl(freq_mib, 4, &curfreq, &len, NULL, 0) != 0) {
@@ -764,6 +767,41 @@
 					freq = freqs[numfreqs - 1];
 			}
 		}
+
+		if (mode == MODE_HYPER) {
+			if (load > cpu_running_mark / 4) {
+				freq = freqs[0];
+				if (curfreq != freq) {
+					if (vflag) {
+						printf("now operating on %s power; "
+					    	"changing frequency to %d MHz\n",
+					    	modes[acline_status], freq);
+					}
+					idle = 0;
+					if (set_freq(freq) != 0) {
+						warn("error setting CPU freq %d",
+				    	    	freq);
+						continue;
+					}
+				}
+			} else {
+				freq = freqs[numfreqs - 1];
+				if (curfreq != freq) {
+					if (vflag) {
+						printf("now operating on %s power; "
+					    	"changing frequency to %d MHz\n",
+					    	modes[acline_status], freq);
+					}
+					idle = 0;
+					if (set_freq(freq) != 0) {
+						warn("error setting CPU freq %d",
+					    	freq);
+						continue;
+					}
+				}
+			}
+		}
+
 		if (vflag) {
 		    printf("load %3d%%, current freq %4d MHz (%2d), wanted freq %4d MHz\n",
 			load, curfreq, i, freq);
Index: usr.sbin/powerd/powerd.8
===================================================================
--- usr.sbin/powerd/powerd.8	(revision 252701)
+++ usr.sbin/powerd/powerd.8	(working copy)
@@ -74,6 +74,13 @@
 will maintain full frequency for longer.
 May be abbreviated as
 .Ar hadp .
+.It Ar hyper
+Immediately drop to the lowest frequency when the system appears to be
+idle.
+When there is any load on the system, immediately jump to the highest
+frequency.
+May be abbreviated as
+.Ar hype .
 .El
 .Pp
 The default mode is
home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1307041955110.10280>