From 9dcefc93041521d2846fa5225703489d8e33a0fd Mon Sep 17 00:00:00 2001 From: Brian Read Date: Wed, 12 Jul 2023 14:07:31 +0100 Subject: [PATCH] initial commit of file from CVS for cpuspeed on Wed 12 Jul 14:07:31 BST 2023 --- .gitattributes | 1 + .gitignore | 3 + Makefile | 21 + README.md | 10 +- contriborbase | 1 + cpuspeed-1.5-Makefile.patch | 33 ++ cpuspeed-1.5-no-affected_cpus-fallback.patch | 96 +++++ cpuspeed-1.5.tar.bz2 | 3 + cpuspeed.8 | 156 ++++++++ cpuspeed.conf | 70 ++++ cpuspeed.init | 399 +++++++++++++++++++ cpuspeed.spec | 366 +++++++++++++++++ license.txt | 341 ++++++++++++++++ 13 files changed, 1499 insertions(+), 1 deletion(-) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 contriborbase create mode 100644 cpuspeed-1.5-Makefile.patch create mode 100644 cpuspeed-1.5-no-affected_cpus-fallback.patch create mode 100644 cpuspeed-1.5.tar.bz2 create mode 100644 cpuspeed.8 create mode 100644 cpuspeed.conf create mode 100755 cpuspeed.init create mode 100644 cpuspeed.spec create mode 100644 license.txt diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5eb6edd --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.tar.bz2 filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1534ba5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.rpm +*.log +*spec-20* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fc8cec0 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Makefile for source rpm: cpuspeed +# $Id: Makefile,v 1.1 2016/03/17 16:10:39 unnilennium Exp $ +NAME := cpuspeed +SPECFILE = $(firstword $(wildcard *.spec)) + +define find-makefile-common +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +endef + +MAKEFILE_COMMON := $(shell $(find-makefile-common)) + +ifeq ($(MAKEFILE_COMMON),) +# attept a checkout +define checkout-makefile-common +test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +endef + +MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) +endif + +include $(MAKEFILE_COMMON) diff --git a/README.md b/README.md index 6c28d3c..d679479 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # cpuspeed -3rd Party (Maintained by Koozali) git repo for cpuspeed smeserver \ No newline at end of file +3rd Party (Maintained by Koozali) git repo for cpuspeed smeserver + +## Description + +
*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.* +*Once it has been checked, then this comment will be deleted* +
+ +The cpuspeed software package is a program that allows users to monitor and control the speed of their computer's processor. It can be used to increase or decrease the processor speed, adjust its power consumption, and view detailed information about the processor. It is typically used to optimize system performance and reduce power consumption. diff --git a/contriborbase b/contriborbase new file mode 100644 index 0000000..ef36a67 --- /dev/null +++ b/contriborbase @@ -0,0 +1 @@ +sme10 diff --git a/cpuspeed-1.5-Makefile.patch b/cpuspeed-1.5-Makefile.patch new file mode 100644 index 0000000..da4a229 --- /dev/null +++ b/cpuspeed-1.5-Makefile.patch @@ -0,0 +1,33 @@ +--- cpuspeed-1.5/Makefile 2008-10-08 15:00:12.000000000 -0400 ++++ cpuspeed-1.5/Makefile.rh 2008-10-08 18:54:03.000000000 -0400 +@@ -1,5 +1,8 @@ +-CC=gcc -Wall -fno-exceptions ++CC=gcc ++CFLAGS=-Wall -fno-exceptions + COPTS=-Os ++LDFLAGS= ++SBINDIR=/usr/sbin + + TARGET=cpuspeed + DEBUG_TARGET=cpuspeed-debug +@@ -9,16 +12,16 @@ debug: $(DEBUG_TARGET) + fake: $(FAKE_TARGET) + + $(TARGET): cpuspeed.cc +- $(CC) -c $(COPTS) cpuspeed.cc +- $(CC) cpuspeed.o -o $(TARGET) +- strip $(TARGET) ++ $(CC) $(CFLAGS) -c $(COPTS) cpuspeed.cc ++ $(CC) $(CFLAGS) $(LDFLAGS) cpuspeed.o -o $(TARGET) + + # Debug target + $(DEBUG_TARGET): cpuspeed.cc + $(CC) -c -g -DDEBUG -o cpuspeed_debug.o cpuspeed.cc + $(CC) cpuspeed_debug.o -o $(DEBUG_TARGET) + +-install: install_redhat ++install: $(TARGET) ++ install -m755 $(TARGET) $(DESTDIR)/$(SBINDIR)/ + + install_redhat: $(TARGET) + cp -f $(TARGET) /sbin diff --git a/cpuspeed-1.5-no-affected_cpus-fallback.patch b/cpuspeed-1.5-no-affected_cpus-fallback.patch new file mode 100644 index 0000000..dd6ac2d --- /dev/null +++ b/cpuspeed-1.5-no-affected_cpus-fallback.patch @@ -0,0 +1,96 @@ +--- cpuspeed-1.5/cpuspeed.cc.orig 2008-10-08 14:59:29.000000000 -0400 ++++ cpuspeed-1.5/cpuspeed.cc 2008-10-08 19:22:33.000000000 -0400 +@@ -159,6 +159,8 @@ unsigned last_step; // lowest speed step + // which CPU cores are we controlling + unsigned tied_cpu_cores[MAX_TIED_CORES]; + unsigned num_tied_cores = 0; ++unsigned cpu = 0; ++bool no_affected_cpus_attr = false; + + // display an error message and exit the program + void +@@ -485,12 +487,16 @@ get_times( + if (nice_counts_as_idle) + { + idle_time += nice_time; ++ } else { ++ user_time += nice_time; + } + + // count IO wait time as idle time + if (io_counts_as_idle) + { + idle_time += wait_time; ++ } else { ++ user_time += wait_time; + } + + unsigned long total_time = user_time + system_time + idle_time; +@@ -711,6 +717,7 @@ unsigned num_cores = 0; // how many CPU + // restore initial speed on program exit + unsigned saved_speed = 0; + char saved_governor[32]; ++pid_t * saved_pids; + + void + term_handler(int which) +@@ -721,6 +728,12 @@ term_handler(int which) + write_line(GOVERNOR_FILE, "%s\n", saved_governor); + } + ++ if (cpu == 0 && no_affected_cpus_attr) ++ { ++ for (unsigned i = 1; i < num_cores; i++) ++ kill(saved_pids[i], which); ++ } ++ + raise(which); + } + +@@ -1036,6 +1049,7 @@ main(int argc, char * argv[]) + // iterate through all cpu cores in main process + for (unsigned i = 0, forked = 0; i < num_cores && !forked; i++) + { ++ int n; + // does this core do cpufreq? + char cpufreq_dir[256]; + snprintf(cpufreq_dir, sizeof cpufreq_dir, SYSFS_CPUFREQ_DIR, i); +@@ -1067,7 +1081,14 @@ main(int argc, char * argv[]) + } + #endif + unsigned cores[MAX_TIED_CORES]; +- int n = read_values(acfn, cores, MAX_TIED_CORES); ++ if (access(acfn, F_OK) != 0) ++ { ++ // fall back to the old 1.2.x method of forking for each core ++ no_affected_cpus_attr = true; ++ n = 1; ++ } ++ else ++ n = read_values(acfn, cores, MAX_TIED_CORES); + + // if we can't figure out the affected cores + if (n == 0) +@@ -1102,8 +1123,22 @@ main(int argc, char * argv[]) + i, cores[0] + ); + #endif ++ if (no_affected_cpus_attr) ++ break; + } + } ++ ++ if (no_affected_cpus_attr) ++ { ++ saved_pids = (pid_t *)calloc(num_cores, sizeof(pid_t)); ++ ++ // fork() a process to handle each core ++ for (unsigned i = 1; i < num_cores; i++) ++ if ( !(saved_pids[i] = fork())) { ++ cpu = i; ++ break; ++ } ++ } + } + + diff --git a/cpuspeed-1.5.tar.bz2 b/cpuspeed-1.5.tar.bz2 new file mode 100644 index 0000000..a64cba8 --- /dev/null +++ b/cpuspeed-1.5.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fd0215ccc73f00a1ab826142749720787594b484c551615909cbfc811912defe +size 13140 diff --git a/cpuspeed.8 b/cpuspeed.8 new file mode 100644 index 0000000..72e2785 --- /dev/null +++ b/cpuspeed.8 @@ -0,0 +1,156 @@ +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. +.TH CPUSPEED "8" "October 08, 2008" "cpuspeed v1.5.1" "Program Options" +.SH NAME +cpuspeed \- user-space cpu frequency scaling program, v1.5.1 +.SH SYNOPSIS +.B cpuspeed +[\fIOptions\fR] +.SH DESCRIPTION +cpuspeed v1.5.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 +.IP +Sets the interval between idle percentage tests and possible speed +changes in tenths of a second (default is 20). +.HP +\fB\-p\fR +.IP +Sets the CPU core idle percentage thresholds. is the idle +percentage below which a CPU core will be set to the highest possible +speed. is the idle percentage above which a CPU core's +speed will be decreased and below which a CPU core's speed will be +increased (defaults are 10 and 25). +.HP +\fB\-m\fR +.IP +Sets the minimum speed in KHz below which a CPU core will not be set. +.HP +\fB\-M\fR +.IP +Sets the maximum speed in KHz above which a CPU core will not be set. +.HP +\fB\-n\fR +.IP +Do not treat niced programs as idle time. +.HP +\fB\-w\fR +.IP +Do not treat time waiting for IO as idle time. +.HP +\fB\-t\fR +.IP +Sets the ACPI temperature file and the temperature at which CPUs +will be set to minimum speed. +.HP +\fB\-T\fR +.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 +.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 +.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 [[] ...] +.IP +Manage only a single group of CPU cores. All of the specified +cores will controlled as a single group (locked to the same speed) +and are in the range 0 to n-1 where 'n' is the total number of CPU +cores in the system. Note that when specifying multiple cores the +list must be enclosed in quotes. Without this option the program +creates copies of itself to manage every core of every CPU in the +system and automatically determines core groups. If you are running +on an old kernel and get an error message about not being able to +open an "affected_cpus" file then you must run this program +separately for each group of cores that must be controlled together +(which probably means for each physical CPU) and use this option. +.SS "Notes:" +To have a CPU core stay at the highest clock speed to maximize performance send +the process controlling that CPU core the SIGUSR1 signal. +.PP +To have a CPU core stay at the lowest clock speed to maximize battery life send +the process controlling that CPU core the SIGUSR2 signal. +.PP +To resume having a CPU core's clock speed dynamically scaled send the process +controlling that CPU core the SIGHUP signal. +.PP +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 \- 2008) +.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 diff --git a/cpuspeed.conf b/cpuspeed.conf new file mode 100644 index 0000000..5b1ec68 --- /dev/null +++ b/cpuspeed.conf @@ -0,0 +1,70 @@ +# /etc/sysconfig/cpuspeed +# +# This configuration file controls the behavior of both the +# cpuspeed daemon and various cpufreq modules. +# For the vast majority of users, there shouldn't be any need to +# alter the contents of this file at all. By and large, frequency +# scaling should Just Work(tm) with the defaults. + +### 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. +# default value: empty (try to auto-detect/use built-in) +DRIVER= + +### GOVERNOR ### +# Which scaling governor to use +# Details on scaling governors for your cpu(s) can be found in +# cpu-freq/governors.txt, part of the kernel-doc package +# NOTES: +# - The GOVERNOR parameter is only valid on centrino, powernow-k8 (amd64) +# and acpi-cpufreq 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 on centrino, powernow-k8, +# and acpi-cpufreq systems, userspace on others) +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 (though only after the +# appropriate drivers have been loaded via the cpuspeed initscript). +# 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" diff --git a/cpuspeed.init b/cpuspeed.init new file mode 100755 index 0000000..75b8eea --- /dev/null +++ b/cpuspeed.init @@ -0,0 +1,399 @@ +#!/bin/sh + +# the following is the LSB init header see +# http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-generic.html#INITSCRCOMCONV +# +### BEGIN INIT INFO +# Provides: cpuspeed +# Should-Start: +# Default-Start: 1 2 3 4 5 +# Short-Description: processor frequency scaling support +# Description: This script enables/disables processor frequency +# scaling support, either using the cpuspeed daemon +# or in-kernel frequency scaling support +### END INIT INFO + +# the following is the chkconfig init header +# +# cpuspeed: processor frequency scaling support +# +# chkconfig: 12345 13 99 +# description: Run dynamic CPU speed daemon and/or load appropriate +# cpu frequency scaling kernel modules and/or governors +# + +# Source function library. +. /etc/rc.d/init.d/functions + +prog="cpuspeed" + +[ -f /usr/sbin/$prog ] || exit 5 + +# Get config. +if [ -f /etc/sysconfig/$prog ]; then + . /etc/sysconfig/$prog +fi + +cpu0freqd=/sys/devices/system/cpu/cpu0/cpufreq +globfreq='/sys/devices/system/cpu' +cpufreq="${globfreq}/cpufreq" +cpus="${globfreq}/cpu[0-9]*" +testpat="${cpus}/cpufreq/scaling_driver" +lockfile="/var/lock/subsys/$prog" +xendir="/proc/xen" +logger="/usr/bin/logger -p info -t $prog" +IGNORE_NICE=${IGNORE_NICE:-0} +module_loaded=false + +some_file_exist() { + while [ "$1" ] ; do + [ -f "$1" ] && return 0 + shift + done + 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} > /dev/null 2>&1` + return $? +} + +is_p4_clockmod() { + if [ `/sbin/lsmod | grep -c -w "p4.clockmod"` -ge 1 -a -d "/sys/devices/system/cpu/cpu0/thermal_throttle" ]; then + return 0 + fi + return 1 +} + +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 + if $(echo ${1} | grep -qE '(threshold|ignore_nice_load)'); then + [ -f $cpufreq/$1 ] && echo $2 > $cpufreq/$1 + else + for cpu in ${cpus}; do + [ -f $cpu/cpufreq/$1 ] && echo $2 > $cpu/cpufreq/$1 + done + fi +} + +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 -r -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 $prog -d $OPTS + RETVAL=$? + return $RETVAL +} + +stop_cpuspeed() { + if [ -n "`pidof $prog`" ]; then + echo -n $"Stopping $prog: " + killproc $prog -USR1 + killproc $prog -INT + fi + if [ -n "`pidof $prog`" ]; then + killproc $prog + fi + RETVAL=$? + return $RETVAL +} + +start() { + if [ $(id -u) -ne 0 ]; then + echo -n "Insufficient privileges to start cpuspeed service: " + failure; echo + return 4 + fi + if [ ! -f $lockfile ] && [ ! -d "$xendir" ]; then + cpu_vendor=$(awk '/vendor_id/{print $3}' /proc/cpuinfo | tail -n 1) + cpu_family=$(awk '/cpu family/{print $4}' /proc/cpuinfo | tail -n 1) + if ! some_file_exist $testpat ; then + # Attempt to load scaling_driver if not loaded + # but it is configured + if [ -n "$DRIVER" ]; then + /sbin/modprobe "$DRIVER" + elif [ -d /proc/acpi ]; then + /sbin/modprobe pcc-cpufreq 2> /dev/null + if [ ! -d ${cpu0freqd} ]; then + /sbin/modprobe -r pcc-cpufreq 2> /dev/null + if [ "$cpu_vendor" == AuthenticAMD ] && [ "$cpu_family" -ge 7 ]; then + # Try loading powernow-k8 if this is an AMD processor, + # family 7 or greater (Athlon XP/MP was family 6) + pk8m=$(/sbin/modinfo powernow-k8 > /dev/null 2>&1) + if [ "$?" -eq 0 ]; then + /sbin/modprobe powernow-k8 2> /dev/null + [ -d ${cpu0freqd} ] || /sbin/modprobe -r powernow-k8 2> /dev/null + fi + else + # use ACPI as a fallback + /sbin/modprobe acpi-cpufreq 2> /dev/null + # if even ACPI didn't work, remove it + # and then next test will bail out. + [ -d ${cpu0freqd} ] || /sbin/modprobe -r acpi-cpufreq 2> /dev/null + fi + fi + fi + if [ ! -d ${cpu0freqd} -a "$cpu_vendor" == GenuineIntel ]; then + # last-ditch effort for Intel proc boxes, try our neutered p4-clockmod + # to get at least passive cooling support (no clock changes) + /sbin/modprobe p4-clockmod 2> /dev/null + [ -d ${cpu0freqd} ] || /sbin/modprobe -r p4-clockmod 2> /dev/null + fi + fi + + # If we get this far with no driver, we must have no scaling. + # We're doomed. + [ ! -f ${cpu0freqd}/scaling_driver ] && return 6 + + # Okay, we have a driver, carry on... + drv=`cat ${cpu0freqd}/scaling_driver` + + # Figure out default governor to use + case "$drv" in + centrino|powernow-k8|pcc-cpufreq|acpi-cpufreq|e_powersaver) + default_governor=ondemand + ;; + p4-clockmod) + # not actually a governor, we want to bail without doing either + # in-kernel scaling or starting up the cpuspeed daemon in this case + default_governor=p4passive + ;; + intel_pstate) + default_governor=powersave + echo "CPU states managed by intel_pstate; use cpupower for configuration." + $logger "CPU states managed by intel_pstate; use cpupower for configuration." + ;; + *) + default_governor=userspace + ;; + esac + governor=${GOVERNOR:-${default_governor}} + + if [ "${governor}" == "p4passive" ]; then + echo -n "Enabling p4-clockmod driver (passive cooling only): " + success; echo + return 0 + fi + + # Load governor module, if need be, and validate + governor_is_module && /sbin/modprobe cpufreq-${governor} + 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 ${default_governor}" + governor_is_module && /sbin/modprobe -r cpufreq-${governor} + governor=${default_governor} + governor_is_module && /sbin/modprobe cpufreq-${governor} + fi + + # Set governor + adjust_cpufreq scaling_governor ${governor} + + # Run cpuspeed daemon for userspace gov, kernel ones otherwise + if [ "${governor}" == "userspace" ]; then + start_cpuspeed + RETVAL=$? + else + if [ -n "$MIN_SPEED" ]; then + adjust_cpufreq scaling_min_freq $MIN_SPEED + else + adjust_cpufreq scaling_min_freq 0 + fi + if [ -n "$MAX_SPEED" ]; then + adjust_cpufreq scaling_max_freq $MAX_SPEED + else + adjust_cpufreq scaling_max_freq `cat $cpu0freqd/cpuinfo_max_freq` + 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: " + success + 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 +} + +stop() { + if [ $(id -u) -ne 0 ]; then + echo -n "Insufficient privileges to stop cpuspeed service: " + failure; echo + return 4 + fi + is_p4_clockmod && p4status="true" + if [ "$p4status" == "true" -a "x${GOVERNOR}" == "x" ]; then + echo "p4-clockmod passive cooling support cannot be truly stopped" + fi + [ ! -f ${cpu0freqd}/scaling_driver ] && return 0 + drv=`cat ${cpu0freqd}/scaling_driver` + governor_module_loaded && module_loaded=true + if [ "${drv}" != "intel_pstate" -a "${governor}" != "userspace" ] || + [ "${drv}" == "intel_pstate" -a "${governor}" != "powersave" ]; then + echo -n "Disabling ${governor} cpu frequency scaling: " + $logger "Disabling ${governor} cpu frequency scaling governor" + for cpu in ${cpus}; do + if [ "${drv}" == "intel_pstate" ]; then + echo powersave > $cpu/cpufreq/scaling_governor + else + echo userspace > $cpu/cpufreq/scaling_governor + cat $cpu/cpufreq/cpuinfo_max_freq > $cpu/cpufreq/scaling_setspeed + fi + done + if [ $module_loaded == true ]; then + /sbin/modprobe -r cpufreq-${governor} + fi + success + RETVAL=0 + else + stop_cpuspeed + RETVAL=$? + fi + echo + [ -n "$DRIVER" ] && /sbin/modprobe -r $DRIVER + [ $RETVAL = 0 ] && RETVAL=$? + [ $RETVAL = 0 ] && rm -f $lockfile + return $RETVAL +} + +reload() { + if [ $(id -u) -ne 0 ]; then + echo -n "Insufficient privileges to stop cpuspeed service: " + failure; echo + return 4 + fi + governor_module_loaded && module_loaded=true + if [ "${governor}" == "userspace" ]; then + failure; echo + return 3 + 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 "Reloading configuration for ${governor}: " + success; echo + return 0 + fi +} + +case "$1" in + start) + start + ;; + + stop) + stop + ;; + + status) + is_p4_clockmod && p4status="true" + if [ "$p4status" == "true" -a "x${GOVERNOR}" == "x" ]; then + echo "p4-clockmod passive cooling is enabled" + exit 0 + fi + governor_module_loaded && module_loaded=true + if [ -d "$xendir" ]; then + echo "Frequency scaling not supported under xen kernels" + RETVAL=0 + elif [ $module_loaded == true -o ${governor} == "performance" ]; then + echo "Frequency scaling enabled using ${governor} governor" + RETVAL=0 + else + status $prog + RETVAL="$?" + fi + ;; + + restart|force-reload) + stop + start + ;; + + reload) + reload + ;; + + condrestart|try-restart) + governor_module_loaded && module_loaded=true + if [ $module_loaded == true -o -n "`pidof $prog`" -o ${governor} == "performance" ]; then + stop + start + fi + ;; + + *) + echo $"Usage: $0 {start|stop|restart|condrestart|status}" + exit 2 + ;; +esac + +exit $RETVAL diff --git a/cpuspeed.spec b/cpuspeed.spec new file mode 100644 index 0000000..d21754b --- /dev/null +++ b/cpuspeed.spec @@ -0,0 +1,366 @@ +Summary: CPU frequency adjusting daemon +Name: cpuspeed +Version: 1.5 +Release: 23%{?dist} +Epoch: 1 +Group: System Environment/Base +License: GPLv2+ +URL: http://carlthompson.net/Software/CPUSpeed +Source0: http://carlthompson.net/downloads/cpuspeed/cpuspeed-%{version}.tar.bz2 +Source1: http://carlthompson.net/downloads/cpuspeed/license.txt +Source2: cpuspeed.init +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: %{ix86} x86_64 ppc ppc64 ia64 sparcv9 sparc64 +Obsoletes: kernel-utils + +Patch1: cpuspeed-1.5-Makefile.patch +Patch2: cpuspeed-1.5-no-affected_cpus-fallback.patch + +%description +cpuspeed is a daemon that dynamically changes the speed +of your processor(s) depending upon its current workload +if it is capable (needs Intel Speedstep, AMD PowerNow!, +or similar support). + +This package also supports enabling cpu frequency scaling +via in-kernel governors on Intel Centrino and AMD +Athlon64/Opteron platforms. + +%prep +%setup -q +cp %{SOURCE1} . +%patch1 -p1 -b .make +%patch2 -p1 -b .ac + +%build +rm -rf $RPM_BUILD_ROOT + +RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS | sed -e 's/-fexceptions/-fno-exceptions/g') +make CFLAGS="$RPM_OPT_FLAGS -fpie -pie" LDFLAGS="-Wl,-z,relro,-z,now" + +%install +mkdir -p $RPM_BUILD_ROOT%{_sbindir} +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d +mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig +mkdir -p $RPM_BUILD_ROOT%{_mandir}/man8/ + +make DESTDIR=$RPM_BUILD_ROOT install +install -m755 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/rc.d/init.d/cpuspeed +install -m644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/cpuspeed +install -m644 %{SOURCE4} $RPM_BUILD_ROOT%{_mandir}/man8/cpuspeed.8 + +%clean +[ "$RPM_BUILD_ROOT" != "/" ] && [ -d $RPM_BUILD_ROOT ] && rm -rf $RPM_BUILD_ROOT; + +%files +%defattr(-,root,root,-) +%doc license.txt CHANGES CONTRIBUTORS EXAMPLES FEATURES README USAGE +%{_sbindir}/cpuspeed +%{_sysconfdir}/rc.d/init.d/cpuspeed +%{_mandir}/man8/* +%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/sysconfig/cpuspeed + +%preun +if [ "$1" = "0" ] ; then + /sbin/service cpuspeed stop >/dev/null 2>&1 || : + /sbin/chkconfig --del cpuspeed +fi + +%post +/sbin/chkconfig --add cpuspeed + +%triggerpostun -- kernel-utils +/sbin/chkconfig --add cpuspeed +exit 0 + +%changelog +* Wed Jul 12 2023 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Thu Mar 17 2016 JP Pialasse - 1:1.5-23 +- Import to Koozali SME Server + +* Tue Jun 16 2015 Petr Šabata - 1:1.5-22 +- Handle scaling governors properly on intel_pstate systems (#1230918) + +* Fri May 29 2015 Petr Šabata - 1:1.5-21 +- Bail out if performance is managed by intel_pstate (#1211828, #1219780, #1225024, #1196755) + +* Fri Jun 28 2013 Petr Šabata - 1:1.5-20 +- Read cpuinfo_max_speed instead of scaling_available_frequencies (#902134) + +* Tue Nov 27 2012 Petr Šabata - 1:1.5-19 +- Fix the naive method of getting the highest available scaling frequency (#876738) + +* Mon Oct 08 2012 Petr Šabata - 1:1.5-18 +- Fix #738463 for real this time. + +* Thu Sep 13 2012 Marcela Mašláňová 1:1.5-17 +- Cpuspeed init script still tries to adjust cpufreq sysfiles on a per core + basis 738463 +- IGNORE_NICE parameter does opposite of what it says (thanks to Minto Joseph) + 797055 +- Cpuspeed does not reset MIN/MAX values when config file is emptied 616976 +- Resolves: rhbz#738463, rhbz#797055, rhbz#616976 + +* Tue Sep 4 2012 Marcela Mašláňová 1:1.5-16 +- Whenever PCC driver is loaded, it loads the “userspace” governor, instead + of the “ondemand” governor. +- Resolves: rhbz#642838 + +* Tue Jul 20 2010 Matthew Garrett 1:1.5-15 +- Init scipt: Add support for loading the pcc-cpufreq driver +- Resolves: rhbz#609659 + +* Wed Jun 30 2010 Petr Sabata - 1:1.5-14 +- Init script: added the reload function +- Init script: the service now stops when using p4-clockmod driver +- Resolves: rhbz#607223 + +* Fri Nov 13 2009 Jarod Wilson 1.5-13 +- Move startup prio so we start after syslog, so any notices during + system startup actually get logged + +* Tue Aug 04 2009 Adam Jackson 1.5-12 +- Move buildroot dir creation to %%install + +* Fri Jul 24 2009 Fedora Release Engineering - 1:1.5-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Fri Jun 26 2009 Jarod Wilson 1.5-10 +- Fix #505837 for real this time, even tested on an actual + p4-clockmod system, seems to DTRT + +* Mon Jun 22 2009 Jarod Wilson 1.5-9 +- Un-pooch fix for #505837 (caused #507216 and didn't work right + to begin with...) + +* Wed Jun 17 2009 Jarod Wilson 1.5-8 +- Let p4-clockmod users override defaults and set a governor, + even if its generally a Bad Idea... (#505837) + +* Wed Jun 10 2009 Jarod Wilson 1.5-7 +- Fix up lsb compliance a bit (#246895) +- Correct a few more exit codes (rhel5 bz, #495049) + +* Tue Mar 17 2009 Jarod Wilson 1.5-6 +- Fix up prior fix-up so that status and stop actually do the right thing + on NON-p4-clockmod systems + +* Fri Mar 06 2009 Jarod Wilson 1.5-5 +- Fix up p4-clockmod support so start/stop/status actually report + something sane to the user + +* Mon Mar 02 2009 Jarod Wilson 1.5-4 +- Fix up ExclusiveArch, now that 32-bit x86 is built i586 for F11 + +* Tue Feb 24 2009 Fedora Release Engineering - 1:1.5-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Mon Nov 03 2008 Jarod Wilson 1.5-2 +- Revive p4-clockmod support, for passive cooling only, when + all else fails on Intel boxes + +* Wed Oct 08 2008 Jarod Wilson 1.5-1 +- Update to v1.5 release + +* Fri Sep 26 2008 Jarod Wilson 1.2.1-9 +- backport proper multicore support for userspace governor + (cpuspeed daemon) case from v1.5 cpuspeed snapshot + +* Tue Jul 15 2008 Tom "spot" Callaway 1.2.1-8 +- fix license tag + +* Sun May 11 2008 Dennis Gilmore 1.2.1-7 +- add sparcv9 sparc64 to list of arches + +* Wed Mar 12 2008 Jarod Wilson 1.2.1-6 +- Minor formatting and redirection fixups + +* Thu Feb 14 2008 Jarod Wilson 1.2.1-5 +- Support for powernow-k8 as a kernel module + +* Tue Feb 12 2008 Jarod Wilson 1.2.1-4 +- Fix up for gcc 4.3 +- Work around multi-core step detection problems (#392781) + +* Wed Aug 29 2007 Jarod Wilson 1.2.1-3 +- Bump and rebuild, due to busted ppc32 + +* Sat Jul 07 2007 Jarod Wilson 1.2.1-2 +- Account for the cpuidle feature in rawhide kernels, + slated for release in kernel 2.6.23 (#247352) + +* Mon Jun 11 2007 Jarod Wilson +- Add e_powersaver (new Via C3 cpufreq driver) to list + of those which should use ondemand governor by default + +* Thu Apr 26 2007 Jarod Wilson +- Add a bit to the config file documentation +- Use variable for program name +- Fix up exit codes (#237942) + +* Mon Mar 12 2007 Jarod Wilson +- Try loading acpi-cpufreq even on machines that don't + report est flag (#231783, #216702) +- Tighten up formatting in initscript + +* Wed Feb 21 2007 Jarod Wilson +- Default to ondemand governor w/acpi-cpufreq driver +- Minor initscript output cleanup + +* Sun Feb 04 2007 Jarod Wilson +- Fix up compile flags and misc other fixes for + core/extras merge review (#225658) + +* Thu Jan 11 2007 Jarod Wilson +- Fix error-suppression for systems that report support + for est, but have it disabled in the bios (#220200) + +* Thu Jan 11 2007 Jarod Wilson +- Fix up documentation in config file (#219926) +- Fall back cleanly to userspace governor on + non-centrino/powernow-k8/p4-clockmod systems +- Update description to reflect support for + kernel-space freq scaling + +* Wed Jan 10 2007 Jarod Wilson +- Fix governor validation check +- Use ondemand by default on p4-clockmod systems + +* Wed Jan 10 2007 Jarod Wilson +- Minor fix for cpuspeed daemon stop function + +* Tue Jan 09 2007 Jarod Wilson +- Turn on ia64 builds (#216702) +- Fix status on xen kernels + +* Tue Jan 09 2007 Jarod Wilson +- Move config file to /etc/sysconfig/cpuspeed, more + appropriate for initscript configs (#152305) +- Manify 'cpuspeed --help' along with other details (#172655) +- Tweak cpuspeed default thresholds (#147565) + +* Mon Jan 08 2007 Jarod Wilson +- Let non-centrino/powernow-k8 systems also use other + validated governors (#219926) +- Fix cpuspeed daemon options settings (#221829) + +* Fri Jan 05 2007 Jarod Wilson +- 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 +- 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 +- Fix busted config file sourcing + +* Mon Nov 27 2006 Jarod Wilson +- Spec tweaks to bring in line with Fedora packaging guidelines +- Add docs to package +- Mark config file as noreplace +- Be sure to stop service before uninstall + +* Tue Nov 21 2006 Dave Jones +- Merge one more patch from Michal Jaegermann (#216816) + +* Mon Nov 20 2006 Dave Jones +- Merge patch from Michal Jaegermann + that solves the acpi-cpufreq problem in an improved + way and fixes several other nits. + +* Sat Oct 28 2006 Dave Jones +- Only load acpi-cpufreq on speedstep capable machines. +- Unload acpi-cpufreq if BIOS tables didn't exist or + other acpi-cpufreq failures occured. + +* Sat Jul 29 2006 Dave Jones +- Don't try to load acpi-cpufreq on non-ACPI machines. (#196446) + +* Wed Jul 26 2006 Dave Jones +- Fix up retval & /var/lock/subsys/cpuspeed handling in initscript. + +* Thu Jul 20 2006 Jim Paradis +- Enable on-demand governor usage for powernow-k8 as well as centrino + +* Wed Jul 12 2006 Jesse Keating - 1:1.2.1-1.35%{dist}.1 +- rebuild + +* Sat Jul 1 2006 Dave Jones +- Fix sched_mc_power_savings warning on centrino laptops. + +* Wed Jun 7 2006 Dave Jones +- Remove a bunch of no-longer needed gunk from the initscript. +- Use on-demand governor on centrino/core based systems for now, + as it seems to have a better effect. + +* Thu Feb 23 2006 Dave Jones +- Fix broken init script. (Alexandre Oliva) [#182691] + Taking ugly shell script to the next level. + +* Tue Feb 21 2006 Dave Jones +- Missed another occurance of the same problem I fixed yesterday. + +* Mon Feb 20 2006 Dave Jones +- Some ACPI BIOSes start counting CPUs at 0, some at 1. *sigh* (#181673) + +* Sat Feb 11 2006 Dave Jones +- rebuild. + +* Thu Feb 09 2006 Dave Jones +- rebuild. + +* Fri Dec 16 2005 Jesse Keating +- rebuilt for new gcj + +* Fri Dec 09 2005 Jesse Keating +- rebuilt + +* Mon Nov 14 2005 Dave Jones +- Don't try and load acpi-cpufreq if we have no throttling states. + +* Thu Sep 29 2005 Dave Jones +- On shutdown, restore speed to maximum before daemon exit. + +* Fri Sep 23 2005 Dave Jones +- Use ACPI as a fallback driver if possible, if one didn't get loaded. (#160788) + +* Mon May 9 2005 Dave Jones +- Fix debuginfo generation. + +* Wed Apr 6 2005 Dave Jones +- Don't count nice time as idle time. (#132383) + +* Tue Mar 1 2005 Dave Jones +- Rebuild for gcc4. + +* Tue Feb 8 2005 Dave Jones +- Rebuild with -D_FORTIFY_SOURCE=2 + +* Fri Feb 4 2005 Dave Jones +- Enable builds for PPC (#147089) + +* Tue Jan 11 2005 Dave Jones +- Add missing Obsoletes: kernel-utils + +* Mon Jan 10 2005 Dave Jones +- Update to upstream 1.2.1 release. + +* Sat Dec 18 2004 Dave Jones +- Initial packaging, split out from kernel-utils. + diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..53f14c7 --- /dev/null +++ b/license.txt @@ -0,0 +1,341 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License.