From owner-freebsd-bugs@FreeBSD.ORG Sun Oct 22 22:10:21 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8C42E16A4AB for ; Sun, 22 Oct 2006 22:10:21 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2E74E43D7D for ; Sun, 22 Oct 2006 22:10:15 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k9MMAFY7054628 for ; Sun, 22 Oct 2006 22:10:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k9MMAEPl054627; Sun, 22 Oct 2006 22:10:14 GMT (envelope-from gnats) Resent-Date: Sun, 22 Oct 2006 22:10:14 GMT Resent-Message-Id: <200610222210.k9MMAEPl054627@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, redchrom@gmail.com Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D74C616A403 for ; Sun, 22 Oct 2006 22:07:52 +0000 (UTC) (envelope-from root@death.ispvds.com) Received: from death.ispvds.com (death.ispvds.com [82.146.33.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 81F0343D4C for ; Sun, 22 Oct 2006 22:07:51 +0000 (GMT) (envelope-from root@death.ispvds.com) Received: by death.ispvds.com (Postfix, from userid 0) id 2C7612E0C07; Sun, 22 Oct 2006 22:07:57 +0000 (UTC) Message-Id: <20061022220757.2C7612E0C07@death.ispvds.com> Date: Sun, 22 Oct 2006 22:07:57 +0000 (UTC) From: redchrom@gmail.com To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: misc/104689: add support for limiting cpu frequency on adaptive mode X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: redchrom@gmail.com List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Oct 2006 22:10:21 -0000 >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@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: