rpms/cpuspeed/FC-6 cpuspeed.8, NONE, 1.1 cpuspeed.conf, NONE, 1.1 cpuspeed.init, 1.15, 1.16 cpuspeed.spec, 1.42, 1.43

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Wed Jan 10 03:23:16 UTC 2007


Author: jwilson

Update of /cvs/dist/rpms/cpuspeed/FC-6
In directory cvs.devel.redhat.com:/tmp/cvs-serv15634

Modified Files:
	cpuspeed.init cpuspeed.spec 
Added Files:
	cpuspeed.8 cpuspeed.conf 
Log Message:
- Turn on ia64 builds (#216702)
- Fix status on xen kernels
- Manify 'cpuspeed --help' along with other details (#172655)
- Tweak cpuspeed default thresholds (#147565)
- Let non-centrino/powernow-k8 systems also use other
  validated governors (#219926)
- Fix cpuspeed daemon options settings (#221829)
- Fix status and condrestart for centrino/powernow-k8 (#219926)
- Give feedback when loading/unloading a cpufreq governor
- Rework config file and initscript to make it much easier
  for end-users to adjust frequency scaling setup (#151761)
- Log start/stop events with useful info
- Don't start on xen kernels (freq scaling not supported)



--- NEW FILE cpuspeed.8 ---
.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.36.
.TH CPUSPEED "8" "January 09, 2005" "cpuspeed v1.2.1" "Program Options"
.SH NAME
cpuspeed \- user-space cpu frequency scaling program, v1.2.1
.SH SYNOPSIS
.B cpuspeed
[\fIOptions\fR]
.SH DESCRIPTION
cpuspeed v1.2.1
.PP
This program monitors the system's idle percentage and reduces or raises the
CPUs' clock speeds and voltages accordingly to minimize power consumption
when idle and maximize performance when needed.  This is the default.
.PP
The program may also optionally be configured to reduce the CPUs' clock
speeds if the temperature gets too high, NOT minimize their speeds if the
computer's AC adapter is disconnected or maximize their speeds when the AC
adapter is connected.
.PP
By default this program will manage every CPU found in the system.
.IP
Options:
.HP
\fB\-d\fR
.IP
Tells the process to daemonize itself (run in background).
.HP
\fB\-i\fR <interval>
.IP
Sets the interval between idle percentage tests and possible speed
changes in tenths of a second (default is 20).
.HP
\fB\-p\fR <fast up> <threshold>
.TP
Sets the CPU idle percentage thresholds.
<fast up> is the idle
.IP
percentage below which a CPU will be set to the highest possible
speed.  <threshold> is the idle percentage above which a CPU's
speed will be decreased and below which a CPU's speed will be
increased (defaults are 10 and 25).
.HP
\fB\-m\fR <minimum speed>
.IP
Sets the minimum speed in KHz below which a CPU will not be set.
.HP
\fB\-M\fR <maximum speed>
.IP
Sets the maximum speed in KHz above which a CPU will not be set.
.HP
\fB\-t\fR <temp file> <maxtemp>
.IP
Sets the ACPI temperature file and the temperature at which CPUs
will be set to minimum speed.
.HP
\fB\-T\fR <interval>
.IP
Sets the interval at which the temperature will be polled in
tenths  of a second (default is 10).
(Requires the '\-t' option above.)
.HP
\fB\-a\fR <AC file>
.IP
Sets the ACPI AC adapter state file and tells the program to set
the CPUs to minimum speed when the AC adapter is disconnected.
(This is the default but is changeable by the '\-D' option below).
.HP
\fB\-A\fR <interval>
.IP
Sets the interval at which the AC adapter state will be polled in
tenths  of a second (default is 50).
(Requires the '\-a' option above.)
.HP
\fB\-C\fR
.IP
Run at maximum speed when AC adapter is connected.
(Requires the '\-a' option above.)
.HP
\fB\-D\fR
.IP
Do NOT force minimum speed when AC adapter is disconnected.
(Requires the '\-a' option above.)
.HP
\fB\-r\fR
.IP
Restores previous speed on program exit.
.HP
\fB\-s\fR <CPU>
.TP
Manage only a single CPU.
<CPU> specifies the number of the CPU
.IP
to manage and is in the range 0 to (n\-1) where 'n' is the number
of CPUs in the system.  Without this option the program creates
copies of itself to manage every CPU in the system.
.IP
To have a CPU stay at the highest clock speed to maximize performance send
the process controlling that CPU the SIGUSR1 signal.
.IP
To have a CPU stay at the lowest clock speed to maximize battery life send
the process controlling that CPU the SIGUSR2 signal.
.IP
To resume having a CPU's clock speed dynamically scaled send the process
controlling that CPU the SIGHUP signal.
.SS "Notes:"
Many modern Linux systems support in-kernel cpu frequency scaling. The
cpuspeed daemon only works in conjunction with the 'userspace' frequency
scaling governor. Other governors, such as 'ondemand' and 'conservative',
rely on the Linux kernel to adjust cpu frequencies on the fly without the
need of any user-space assistance, such as that provided by cpuspeed.
.PP
Red Hat and Fedora distributions employ a unified configuration file
for both scenarios, as well as a cpuspeed init script that will configure
either cpuspeed or in-kernel cpu frequency scaling, as appropriate.
.SH "FILES"
.na
.nf
/etc/sysconfig/cpuspeed, configuration file
/etc/init.d/cpuspeed, initialzation script
/usr/sbin/cpuspeed, cpuspeed program
.SH "SEE ALSO"
.PP
The CPUSpeed web page:
  \fB http://carlthompson.net/Software/CPUSpeed\fR
.SH "LICENSE"
.PP
CPUSpeed is released under the GNU General Public License version 2 (or if
you wish any later version). This license allows you to use, copy,
distribute and modify the software with very few restrictions. The full
text of the license may be found here:
  \fBhttp://carlthompson.net/Software/CPUSpeed/License\fR
.SH "AUTHOR(S):"
.TP
CPUSpeed daemon, original init script and configuration file:
.na
.nf
Carl Thompson \- cet [at] carlthompson.net
    (copyright 2002 \- 2005)
.TP
Modernized init script, configuration file and man page:
.na
.nf
Dave Jones \- davej [at] redhat.com
Michal Jaegermann \- michal [at] harddata.com
Jarod Wilson \- jwilson [at] redhat.com


--- NEW FILE cpuspeed.conf ---
# /etc/cpuspeed.conf
#
# This configuration file controls the behavior of both the
# cpuspeed daemon and various cpufreq modules.

### DRIVER ###
# Your CPUFreq driver module
# Note that many drivers are now built-in, rather than built as modules,
# so its usually best not to specify one. The most commonly-needed driver
# module these days is 'p4-clockmod'.
# default value: empty (auto-detect/use built-in)
DRIVER=

### GOVERNOR ###
# Which scaling governor to use
# Valid scaling governors for your cpu(s) can be found in
# /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_governors
# on systems that support frequency scaling.
# NOTES:
# - The GOVERNOR parameter is only valid on centrino and powernow-k8 (amd64)
#   platforms, other platforms that support frequency scaling always use
#   the 'userspace' governor.
# - Using the 'userspace' governor will trigger the cpuspeed daemon to run,
#   which provides said user-space frequency scaling.
# default value: empty (defaults to ondemand)
GOVERNOR=

### FREQUENCIES ###
# NOTE: valid max/min frequencies for your cpu(s) can be found in
# /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies
# on systems that support frequency scaling.
# maximum speed to scale up to
# default value: empty (use cpu reported maximum)
MAX_SPEED=
# minimum speed to scale down to
# default value: empty (use cpu reported minimum)
MIN_SPEED=

### SCALING THRESHOLDS ###
# Busy percentage threshold over which to scale up to max frequency
# default value: empty (use governor default)
UP_THRESHOLD=
# Busy percentage threshold under which to scale frequency down
# default value: empty (use governor default)
DOWN_THRESHOLD=

### NICE PROCESS HANDLING ###
# Let background (nice) processes speed up the cpu
# default value: 0 (background process usage can speed up cpu)
# alternate value: 1 (background processes will be ignored)
IGNORE_NICE=0


#####################################################
########## HISTORICAL CPUSPEED CONFIG BITS ##########
#####################################################
VMAJOR=1
VMINOR=1

# Add your favorite options here
#OPTS="$OPTS -s 0 -i 10 -r"

# uncomment and modify this to check the state of the AC adapter
#OPTS="$OPTS -a /proc/acpi/ac_adapter/*/state"

# uncomment and modify this to check the system temperature
#OPTS="$OPTS -t /proc/acpi/thermal_zone/*/temperature 75"


Index: cpuspeed.init
===================================================================
RCS file: /cvs/dist/rpms/cpuspeed/FC-6/cpuspeed.init,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- cpuspeed.init	29 Nov 2006 22:10:51 -0000	1.15
+++ cpuspeed.init	10 Jan 2007 03:23:13 -0000	1.16
@@ -2,7 +2,8 @@
 # Startup script for cpuspeed
 #
 # chkconfig: 12345 06 99
-# description: Run dynamic CPU speed daemon
+# description: Run dynamic CPU speed daemon and/or load appropriate
+#              cpu frequency scaling kernel modules and governors
 
 # Source function library.
 . /etc/rc.d/init.d/functions
@@ -17,7 +18,13 @@
 fi
 
 cpu0freqd=/sys/devices/system/cpu/cpu0/cpufreq
-testpat='/sys/devices/system/cpu/cpu*/cpufreq/scaling_driver'
+cpus='/sys/devices/system/cpu/cpu*'
+testpat="${cpus}/cpufreq/scaling_driver"
+lockfile="/var/lock/subsys/$prog"
+xendir="/proc/xen"
+logger="/usr/bin/logger -p info -t cpuspeed"
+module_loaded=false
+is_module=false
 
 some_file_exist() {
 	while [ "$1" ] ; do
@@ -27,8 +34,84 @@
 	return 1
 }
 
+governor_is_module() {
+	# Check to see if the requested cpufreq governor
+	# is provided as a kernel module or not
+	module_info=`/sbin/modinfo cpufreq-${governor} 2>&1 > /dev/null`
+	return $?
+}
+
+governor_module_loaded() {
+	# Check to see if we have a module loaded for
+	# the current cpufreq governor
+	if [ -e ${cpu0freqd}/scaling_governor ]; then
+	    governor=`cat ${cpu0freqd}/scaling_governor`
+	else
+	    governor="none"
+	fi
+	if [ "${governor}" != "none" -a `/sbin/lsmod | grep -c -w "cpufreq.${governor}"` -ge 1 ] ; then
+            return 0
+	fi
+	return 1
+}
+
+adjust_cpufreq() {
+	# First arg is a param under $cpu/cpufreq/
+	# Second arg is the value you want to set that param to
+	for cpu in ${cpus}; do
+	    echo $2 > $cpu/cpufreq/$1
+	done
+}
+
+start_cpuspeed() {
+	echo -n $"Starting $prog: "
+	# cpuspeed daemon thresholds are specified as idle percentages,
+	# cpufreq modules as busy percentages, so we need to do some
+	# math here for use of unified config...
+	# DOWN_THRESHOLD doesn't mean exactly the same thing for
+	# cpuspeed as it does for the cpufreq governors, but close
+	# enough, and if not specified, we use same defaults as governors.
+	if [ -n "$UP_THRESHOLD" ]; then
+	    let UP_THRESHOLD=100-$UP_THRESHOLD
+	else
+	    UP_THRESHOLD=20
+	fi
+	if [ -n "$DOWN_THRESHOLD" ]; then
+	    let DOWN_THRESHOLD=100-$DOWN_THRESHOLD
+	else
+	    DOWN_THRESHOLD=80
+	fi
+	OPTS="$OPTS -p $UP_THRESHOLD $DOWN_THRESHOLD"
+	if [ -n "$MIN_SPEED" ]; then
+	    OPTS="$OPTS -m $MIN_SPEED"
+	fi
+	if [ -n "$MAX_SPEED" ]; then
+	    OPTS="$OPTS -M $MAX_SPEED"
+	fi
+	if [ $IGNORE_NICE -eq 0 ]; then
+	    OPTS="$OPTS -n"
+	fi
+	daemon cpuspeed -d $OPTS
+	RETVAL=$?
+	return $RETVAL
+}
+
+stop_cpuspeed() {
+	echo -n $"Stopping $prog: "
+	if [ -n "`pidof cpuspeed`" ]; then
+	    killproc cpuspeed -USR1
+	    killproc cpuspeed -INT
+	    RETVAL=$?
+	fi
+	if [ -n "`pidof cpuspeed`" ]; then
+	    killproc cpuspeed
+	    RETVAL=$?
+	fi
+	return $RETVAL
+}
+
 start() {
-	if [ ! -f /var/lock/subsys/cpuspeed ] ; then
+	if [ ! -f $lockfile ] && [ ! -d "$xendir" ]; then
 		if ! some_file_exist $testpat ; then
 			# Attempt to load scaling_driver if not loaded
 			# but it is configured
@@ -40,11 +123,11 @@
 					grep flags /proc/cpuinfo | \
 						grep -q est ; then
 					# use ACPI as a fallback 
-					/sbin/modprobe acpi-cpufreq
+					/sbin/modprobe acpi-cpufreq 2>&1 > /dev/null
 					# if even ACPI didn't work, remove it
 					# and then next test will bail out.
 					[ -d ${cpu0freqd} ] || \
-						/sbin/modprobe -r acpi-cpufreq
+						/sbin/modprobe -r acpi-cpufreq 2>&1 > /dev/null
 				else
 					# No scaling. Just exit.
 					return 0
@@ -60,21 +143,56 @@
 
 		case "$drv" in
 		centrino|powernow-k8)
-			/sbin/modprobe cpufreq-ondemand
-			for i in /sys/devices/system/cpu/cpu*
-			do
-				echo ondemand > $i/cpufreq/scaling_governor
-			done
-			RETVAL=0
+			governor=${GOVERNOR:-governor}
 			;;
 		*)
-			echo -n $"Starting $prog: "
-			daemon cpuspeed -d $OPTS
-			RETVAL=$?
-			echo
-			[ $RETVAL = 0 ] && touch /var/lock/subsys/cpuspeed
+			governor=${GOVERNOR:-userspace}
+			;;
 		esac
+		if [ `grep -c -w ${governor} ${cpu0freqd}/scaling_available_governors` -ge 1 ] ; then
+		    $logger "Enabling ${governor} cpu frequency scaling governor"
+		else
+		    $logger "Invalid governor \"${governor}\" specified, falling back to ondemand"
+		    governor="ondemand"
+		fi
+		governor_is_module && is_module=true
+		if [ $is_module == true ]; then
+		    /sbin/modprobe cpufreq-${governor}
+		fi
+		adjust_cpufreq scaling_governor ${governor}
+		# cpuspeed daemon only runs w/userspace governor
+		if [ "${governor}" == "userspace" ]; then
+		    start_cpuspeed
+		    RETVAL=$?
+		else
+		    if [ -n "$MIN_SPEED" ]; then
+		        adjust_cpufreq scaling_min_freq $MIN_SPEED
+		    fi
+		    if [ -n "$MAX_SPEED" ]; then
+		        adjust_cpufreq scaling_max_freq $MAX_SPEED
+		    fi
+		    if [ -n "$UP_THRESHOLD" -a ${governor} == "ondemand" ]; then
+		        adjust_cpufreq ondemand/up_threshold $UP_THRESHOLD
+		    fi
+		    if [ -n "$DOWN_THRESHOLD" -a ${governor} == "conservative" ]; then
+		        adjust_cpufreq conservative/down_threshold $DOWN_THRESHOLD
+		    fi
+		    if [ "$IGNORE_NICE" -eq 1 -a ${governor} == "ondemand" -o ${governor} == "conservative" ]; then
+		        adjust_cpufreq ${governor}/ignore_nice_load $IGNORE_NICE
+		    fi
+		    echo -n "Enabling ${governor} cpu frequency scaling: "
+		    daemon :
+		    RETVAL=0
+		fi
+		echo
+		# Technically, not quite right in non-cpuspeed daemon
+		# cases, but close enough to indicate that we're
+		# doing some sort of cpu frequency scaling.
+		[ $RETVAL = 0 ] && touch $lockfile
 	else
+		if [ -d "$xendir" ]; then
+		    $logger "CPU Frequency scaling is currently not supported on xen kernels"
+		fi
 		return 0
 	fi
 	return $RETVAL
@@ -83,27 +201,29 @@
 stop() {
 	[ ! -f ${cpu0freqd}/scaling_driver ] && return 0
 	drv=`cat ${cpu0freqd}/scaling_driver`
+	governor_module_loaded && module_loaded=true
 
-	case "$drv" in
-	centrino|powernow-k8)
-		/sbin/modprobe -r cpufreq-ondemand
-		RETVAL=0
-		;;
-	*)
-		if test "x`pidof cpuspeed`" != x; then
-			echo -n $"Stopping $prog: "
-			killproc cpuspeed -USR1
-			killproc cpuspeed -INT
-			echo
-		fi
-		if test "x`pidof cpuspeed`" != x; then
-			killproc cpuspeed
-		fi
-		RETVAL=$?
-	esac
+	if [ "${governor}" != "userspace" ]; then
+	    echo -n "Disabling ${governor} cpu frequency scaling: "
+	    $logger "Disabling ${governor} cpu frequency scaling governor"
+	    for cpu in ${cpus}
+	    do
+	        echo userspace > $cpu/cpufreq/scaling_governor
+	        cat $cpu/cpufreq/cpuinfo_max_freq > $cpu/cpufreq/scaling_setspeed
+	    done
+	    if [ $module_loaded == true ]; then
+	        /sbin/modprobe -r cpufreq-${governor}
+	    fi
+	    daemon :
+	    RETVAL=0
+	else
+	    stop_cpuspeed
+	    RETVAL=$?
+	fi
+	echo
 	[ -n "$DRIVER" ] && /sbin/modprobe -r $DRIVER
 	[ $RETVAL = 0 ] && RETVAL=$?
-	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/cpuspeed
+	[ $RETVAL = 0 ] && rm -f $lockfile
 	return $RETVAL
 }
 
@@ -117,14 +237,24 @@
 	    ;;
 
 	status)
-	    status cpuspeed
+	    governor_module_loaded && module_loaded=true
+	    if [ -d "$xendir" ]; then
+	        echo "Frequency scaling not support under xen kernels"
+	    elif [ $module_loaded == true -o ${governor} == "performance" ]; then
+	        echo "Frequency scaling enabled using ${governor} governor"
+	    else
+	        status cpuspeed
+	    fi
 	    ;;
 	restart)
 	    stop
 	    start
 	    ;;
 	condrestart)
-	    if test "x`pidof cpuspeed`" != x; then
+	    governor_module_loaded && module_loaded=true
+	    if [ $module_loaded == true -o \
+	         -n "`pidof cpuspeed`" -o \
+	         ${governor} == "performance" ] ; then
 		stop
 		start
 	    fi


Index: cpuspeed.spec
===================================================================
RCS file: /cvs/dist/rpms/cpuspeed/FC-6/cpuspeed.spec,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- cpuspeed.spec	29 Nov 2006 22:10:51 -0000	1.42
+++ cpuspeed.spec	10 Jan 2007 03:23:14 -0000	1.43
@@ -9,13 +9,15 @@
 Source0:        http://carlthompson.net/dl/cpuspeed/cpuspeed-%{version}.tar.gz
 Source1:        cpuspeed.init
 Source2:        http://carlthompson.net/dl/cpuspeed/license.txt
+Source3:        cpuspeed.conf
+Source4:        cpuspeed.8
 Buildroot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Requires(post):  /sbin/chkconfig
 Requires(preun): /sbin/chkconfig
 Requires(preun): /sbin/service
 
 BuildRequires:  automake util-linux groff gettext
-ExclusiveArch:	i386 x86_64 ppc ppc64
+ExclusiveArch:	i386 x86_64 ppc ppc64 ia64
 Obsoletes:	kernel-utils
 
 Patch1: warning.diff
@@ -42,14 +44,15 @@
 
 mkdir -p %{buildroot}%{_sbindir}
 mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d
-mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
+mkdir -p %{buildroot}%{_mandir}/man8/
 
 make CFLAGS="$RPM_OPT_FLAGS -fpie -pie -Wl,-z,relro,-z,now"
 
 %install
 install cpuspeed %{buildroot}%{_sbindir}
 install %{SOURCE1} %{buildroot}%{_sysconfdir}/rc.d/init.d/cpuspeed
-install cpuspeed.conf %{buildroot}%{_sysconfdir}
+install %{SOURCE3} %{buildroot}%{_sysconfdir}/
+install %{SOURCE4} %{buildroot}%{_mandir}/man8/cpuspeed.8
 
 chmod -R a-s %{buildroot}
 
@@ -61,6 +64,7 @@
 %doc license.txt CHANGES EXAMPLES FEATURES README USAGE
 %{_sbindir}/cpuspeed
 %{_sysconfdir}/rc.d/init.d/cpuspeed
+%{_mandir}/man8/*
 %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/cpuspeed.conf
 
 %preun
@@ -77,6 +81,26 @@
 exit 0
 
 %changelog
+* Wed Jan 10 2007 Jarod Wilson <jwilson at redhat.com>
+- Turn on ia64 builds (#216702)
+- Fix status on xen kernels
+- Manify 'cpuspeed --help' along with other details (#172655)
+- Tweak cpuspeed default thresholds (#147565)
+- Let non-centrino/powernow-k8 systems also use other
+  validated governors (#219926)
+- Fix cpuspeed daemon options settings (#221829)
+- Fix status and condrestart for centrino/powernow-k8 (#219926)
+- Give feedback when loading/unloading a cpufreq governor
+- Rework config file and initscript to make it much easier
+  for end-users to adjust frequency scaling setup (#151761)
+- Log start/stop events with useful info
+- Don't start on xen kernels (freq scaling not supported)
+
+* Thu Dec 14 2006 Jarod Wilson <jwilson at redhat.com>
+- Set lock file for centrino/powernow-k8 so status 
+  indicates we do have scaling working 
+- Fix up centrino/powernow-k8 stop function (#213999)
+
 * Wed Nov 29 2006 Jarod Wilson <jwilson at redhat.com>
 - Fix busted config file sourcing
 




More information about the fedora-cvs-commits mailing list