From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sa.int.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Date: Fri, 4 Nov 2011 18:32:31 +0200 From: Michael Shigorin To: ALT Linux Community general discussions Message-ID: <20111104163231.GD13267@osdn.org.ua> Mail-Followup-To: ALT Linux Community general discussions References: <20110919212524.4a54ac43@c203.office.altlinux.ru> <20110923140715.GC3506@osdn.org.ua> <20111020183651.576b8b2f@c203.office.altlinux.ru> <20111021174226.GD16649@osdn.org.ua> <20111104014856.572494c6@sem-notebook> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9zSXsLTf0vkW971A" Content-Disposition: inline In-Reply-To: <20111104014856.572494c6@sem-notebook> User-Agent: Mutt/1.4.2.1i Subject: Re: [Comm] cpufreq-simple (was: Simply Linux DVD beta) X-BeenThere: community@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: shigorin@gmail.com, ALT Linux Community general discussions List-Id: ALT Linux Community general discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2011 16:32:37 -0000 Archived-At: List-Archive: List-Post: --9zSXsLTf0vkW971A Content-Type: multipart/mixed; boundary="oyUTqETQ0mS9luUI" Content-Disposition: inline --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 04, 2011 at 01:48:56AM +0400, Mikhail Efremov wrote: > =F1 =D3=C4=C5=CC=C1=CC =D0=D2=CF=D3=D4=C5=CE=D8=CB=C9=CA =D0=C1=CB=C5=D4 = cpufreq-simple, =CF=CE =D5=CD=C5=C5=D4 =D4=CF=CC=D8=CB=CF > =D0=C5=D2=C5=CB=CC=C0=DE=C1=D4=D8 governor =D0=D2=C9 =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D2=CF=D7=C1=D4=D8, =C5=D3=CC=C9 =CE=C5 =C2=D5=C4= =C5=D4 =D0=D2=CF=C2=CC=C5=CD > - =D7=CB=CC=C0=DE=D5 =D7 =F3=C9=CD=D0=CC=C9. =F0=D2=CF=DB=A3=CC =DE=D5=D4=D8 =CE=C1=D0=C9=CC=D8=CE=C9=CB=CF=CD: (=D5=D0= =D3, git.alt =D0=D2=C9=CC=A3=C7 =C2=D5=C4=D4=CF, =D0=D2=C9=CC=C1=C7=C1=C0); =D2=C1=DA=D5=CD=C5=C5=D4=D3=D1, =D3=D4=CF=C9=D4 =D7=CB=CC=C0=DE=C9=D4=D8, = =D7 mkimage-profiles =CF=C2=D1=DA=C1=D4=C5=CC=D8=CE=CF =C4=CF=C2=C1=D7=CC= =C0. =F0=D2=C9=DE=A3=CD =D7 =C9=CE=C9=D4=D3=CB=D2=C9=D0=D4=C5 =D0=CF=D0=D2=C1=D7= =C9=CC =CE=C1 =D3=D4=C1=D2=D4 =D0=CF =D5=CD=CF=CC=DE=C1=CE=C9=C0, =DE=D4=CF= =C2 =CE=C5 =C2=D9=CC=CF =CB=CF=CE=C6=D5=DA=CF=D7 =D7=C9=C4=C1 "=CB=CF=CC=CF=D2=C9=CD=C5=D4=D2 =D2= =C1=C2=CF=D4=C1=C5=D4, =C9=D3=D0=D2=C1=D7=CE=CF =CC=C5=D6=C9=D4 =D7 =D3=C5= =CA=C6=C5"... =F3=D0=C1=D3=C9=C2=CF, =D4=A3=DA=CB=C1! --=20 ---- WBR, Michael Shigorin ------ Linux.Kiev http://www.linux.kiev.ua/ --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-reworked-scripts-and-defautls-a-bit.patch" Content-Transfer-Encoding: quoted-printable =46rom 97a0a4d29d6f95930fa43127b5cc23b765ca4016 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Fri, 4 Nov 2011 18:17:25 +0200 Subject: [PATCH 1/2] reworked scripts and defautls a bit Added: - "unknown" AC state (defaulting to ondemand governor) - attempt to load the missing governor module - libshell use for error reporting Changed: - service is on by default: it's pretty safe, remove the package if unneeded - default AC_ON state CPU governor changed to ondemand: it is vastly preferred to performance governor in either notebook, desktop, or server case regarding power, heat, and noise --- cpufreq-simple/cpufreq-simple | 38 +++++++++++++++++++--------= --- cpufreq-simple/cpufreq-simple.init | 11 ++++----- cpufreq-simple/cpufreq-simple.sysconfig | 5 +++- 3 files changed, 33 insertions(+), 21 deletions(-) mode change 100644 =3D> 100755 cpufreq-simple/cpufreq-simple mode change 100644 =3D> 100755 cpufreq-simple/cpufreq-simple.sysconfig diff --git a/cpufreq-simple/cpufreq-simple b/cpufreq-simple/cpufreq-simple old mode 100644 new mode 100755 index 3bef32d..50931e7 --- a/cpufreq-simple/cpufreq-simple +++ b/cpufreq-simple/cpufreq-simple @@ -4,18 +4,25 @@ CPU=3D GOVERNOR_AC_ON=3D GOVERNOR_AC_OFF=3D =20 +. shell-error + [ -f /etc/sysconfig/cpufreq-simple ] && . /etc/sysconfig/cpufreq-simple =20 CPUFREQ=3D/sys/devices/system/cpu/cpu0/cpufreq +GOVERNORS=3D"$CPUFREQ/scaling_available_governors" cmd=3D"${1-}" =20 get_ac_state() { - [ -d /proc/acpi/ac_adapter/ ] || return 1 - - local state_file=3D"$(find /proc/acpi/ac_adapter/ -name state | head -1)" - - [ -n "$state_file" -a -r "$state_file" ] && sed 's;^state:[[:blank:]]*;;'= "$state_file" | head -1 + local state_file + if [ -d /proc/acpi/ac_adapter/ ]; then + state_file=3D"$(find /proc/acpi/ac_adapter/ -name state | head -1)" + if [ -n "$state_file" -a -r "$state_file" ]; then + sed 's;^state:[[:blank:]]*;;' "$state_file" | head -1 + fi + else + echo "unknown" + fi } =20 init_command() @@ -26,27 +33,28 @@ init_command() =20 set_cpufreq() { + # getopt seems overkill right now + if [ "$1" =3D "-g" -a -n "$2" ]; then + grep -Fq -- "$2" "$GOVERNORS" || modprobe "cpufreq_$2" + fi for i in $CPU; do cpufreq-set -c "$i" "$@" done } =20 -if ! [ -f "$CPUFREQ/scaling_governor" -a -f "$CPUFREQ/scaling_available_go= vernors" ]; then - echo "Your system is not configured correctly to support cpu frequency sc= aling" >&2 - exit 1 +if ! [ -f "$CPUFREQ/scaling_governor" -a -f "$GOVERNORS" ]; then + fatal "system not configured correctly for CPU frequency scaling" fi =20 [ -n "$cmd" ] || cmd=3D"$(init_command)" =20 if [ -z "$cmd" ]; then - echo "Couldn't to set initial settings" >&2 - exit 1 + fatal "couldn't apply initial settings" fi =20 [ -n "$CPU" ] || CPU=3D"$(grep '^processor' /proc/cpuinfo | sed 's/^.*: //= ;' | tr '\n' ' ')" if [ -z "$CPU" ]; then - echo "Couldn't to detect CPUs number" >&2 - exit 1 + fatal "couldn't detect the number of CPUs" fi =20 case "$cmd" in @@ -56,8 +64,10 @@ case "$cmd" in ac-off-line) [ -z "$GOVERNOR_AC_OFF" ] || set_cpufreq -g "$GOVERNOR_AC_OFF" ;; + ac-unknown) + [ -z "$GOVERNOR_AC_UNKNOWN" ] || set_cpufreq -g "$GOVERNOR_AC_UNKNOWN" + ;; *) - echo "Unknown command: '$cmd'" >&2 - exit 1 + fatal "unknown command: '$cmd'" ;; esac diff --git a/cpufreq-simple/cpufreq-simple.init b/cpufreq-simple/cpufreq-si= mple.init index 5c765e2..e836533 100644 --- a/cpufreq-simple/cpufreq-simple.init +++ b/cpufreq-simple/cpufreq-simple.init @@ -2,9 +2,8 @@ # # Load kernel modules needed to enable cpufreq scaling # -# chkconfig: - 12 90 -# description: Make it possible to save power by reducing -# the CPU speed when there is little to do. +# chkconfig: 345 12 90 +# description: Save power when idling =20 # Do not load RH compatibility interface. WITHOUT_RC_COMPAT=3D1 @@ -48,7 +47,7 @@ start() echo =20 if [ $RETVAL -eq 0 ]; then - action "Set cpufreq settings: " cpufreq-simple + action "Tune up cpufreq: " cpufreq-simple RETVAL=3D"$?" fi =20 @@ -79,8 +78,8 @@ case "$1" in # Nothing to do ;; status) - is_loaded && echo "Cpufreq is enabled" || - echo "Cpufreq is disabled" + is_loaded && echo "cpufreq is enabled" || + echo "cpufreq is disabled" ;; *) msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|cond= reload|status}" diff --git a/cpufreq-simple/cpufreq-simple.sysconfig b/cpufreq-simple/cpufr= eq-simple.sysconfig old mode 100644 new mode 100755 index db6057f..abe63a1 --- a/cpufreq-simple/cpufreq-simple.sysconfig +++ b/cpufreq-simple/cpufreq-simple.sysconfig @@ -3,11 +3,14 @@ #CPU=3D =20 # Scalling governor used when AC is on. -GOVERNOR_AC_ON=3Dperformance +GOVERNOR_AC_ON=3Dondemand =20 # Scalling governor used when AC is off. GOVERNOR_AC_OFF=3Dondemand =20 +# Scalling governor used when AC state is unknown. +GOVERNOR_AC_UNKNOWN=3Dondemand + # Cpufreq module. If not set then will be detected # automatically by detect-cpufreq-module script. #MODULE=3D --=20 1.7.7.1 --oyUTqETQ0mS9luUI Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0002-0.1.1-alt1.patch" Content-Transfer-Encoding: quoted-printable =46rom 427bf13c28652c1a54d568baae43d955d747d617 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Fri, 4 Nov 2011 18:23:05 +0200 Subject: [PATCH 2/2] 0.1.1-alt1 - Minor fixups all over the place. - Enabled the service by default. --- cpufreq-simple.spec | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cpufreq-simple.spec b/cpufreq-simple.spec index dea8c48..edc4ab7 100644 --- a/cpufreq-simple.spec +++ b/cpufreq-simple.spec @@ -1,5 +1,5 @@ Name: cpufreq-simple -Version: 0.1.0 +Version: 0.1.1 Release: alt1 =20 Summary: Simple scripts for managing CPUfreq settings @@ -11,20 +11,22 @@ BuildArch: noarch =20 BuildRequires(pre): rpm-build-licenses =20 -Requires: cpufrequtils +Requires: cpufrequtils libshell =20 %description -Simple scripts for managing CPUfreq settings +Install this package if you would like it to attempt +cpufreq autoconfiguration in order to save power +as well as reduce heat and noise. =20 %prep %setup =20 %install -install -Dm0755 %name %buildroot%_bindir/cpufreq-simple -install -Dm0755 detect-cpufreq-module %buildroot%_bindir/detect-cpufreq-mo= dule -install -Dm0755 %name.init %buildroot%_initdir/%name -install -Dm0744 96-%name.rules %buildroot%_sysconfdir/udev/rules.d/96-%nam= e.rules -install -Dm0744 %name.sysconfig %buildroot%_sysconfdir/sysconfig/%name +install -pDm755 %name %buildroot%_bindir/cpufreq-simple +install -pDm755 detect-cpufreq-module %buildroot%_bindir/detect-cpufreq-mo= dule +install -pDm755 %name.init %buildroot%_initdir/%name +install -pDm644 96-%name.rules %buildroot%_sysconfdir/udev/rules.d/96-%nam= e.rules +install -pDm644 %name.sysconfig %buildroot%_sysconfdir/sysconfig/%name =20 %post %post_service %name @@ -39,6 +41,10 @@ install -Dm0744 %name.sysconfig %buildroot%_sysconfdir/s= ysconfig/%name %_sysconfdir/udev/rules.d/*.rules =20 %changelog +* Fri Nov 04 2011 Michael Shigorin 0.1.1-alt1 +- Minor fixups all over the place. +- Enabled the service by default. + * Thu Nov 03 2011 Mikhail Efremov 0.1.0-alt1 - Initial build. =20 --=20 1.7.7.1 --oyUTqETQ0mS9luUI-- --9zSXsLTf0vkW971A Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFOtBOfbsPDprYMm3IRAmmYAJ9ZFdkPuMc8L5kdikODMnQkpFsLdQCgnPji 6ehHNdTR7b4XAqrsGNJx0uM= =Zz7u -----END PGP SIGNATURE----- --9zSXsLTf0vkW971A--