diff --git a/ktune/ktune.init b/ktune/ktune.init index 8fcae1d..1c08d28 100644 --- a/ktune/ktune.init +++ b/ktune/ktune.init @@ -30,6 +30,8 @@ KERNEL_ELEVATOR="cfq" CMDLINE_ELEVATOR=$? SYS_BLOCK_SDX=$(eval LANG=C /bin/ls -1 ${ELEVATOR_TUNE_DEVS} 2>/dev/null) +CMDLINE_ARG1=$1 + declare -a KTUNE_FILES if [ -r "$SYSCTL" ]; then KTUNE_FILES[0]="$SYSCTL" @@ -85,7 +87,7 @@ call_script() { if [ -x "$script" ]; then echo -n "Calling "$script": " - ("$script") + ("$script ${CMDLINE_ARG1}") ret=$? if [ $ret -eq 0 ]; then diff --git a/tune-profiles/desktop-powersave/ktune.sh b/tune-profiles/desktop-powersave/ktune.sh index 67f5ce6..d13fc81 100644 --- a/tune-profiles/desktop-powersave/ktune.sh +++ b/tune-profiles/desktop-powersave/ktune.sh @@ -3,12 +3,72 @@ ALPM="medium_power" # Set ALPM for all host adapters that support it -for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do - hotplug="0" - if [ -e $x/sata_hotplug ]; then - hotplug="$(cat $x/sata_hotplug)" - fi - if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then - echo $ALPM > $x/link_power_management_policy - fi -done +set_alpm() { + for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do + hotplug="0" + if [ -e $x/sata_hotplug ]; then + hotplug="$(cat $x/sata_hotplug)" + fi + if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then + echo $1 > $x/link_power_management_policy + fi + done +} + +start() { + set_alpm ${ALPM} + return 0 +} + +# Disable ALPM for all host adapters that support it +stop() { + set_alpm "max_power" + return 0 +} + +# Reload it, just start once more +reload() { + start +} + +# Status +status() { + return 0 +} + + +case "$1" in + start) + [ -f "$VAR_SUBSYS_KTUNE" ] && exit 0 + start + RETVAL=$? + ;; + stop) + [ -f "$VAR_SUBSYS_KTUNE" ] || exit 0 + stop + RETVAL=$? + ;; + reload) + [ -f "$VAR_SUBSYS_KTUNE" ] && reload + RETVAL=$? + ;; + restart|force-reload) + [ -f "$VAR_SUBSYS_KTUNE" ] && stop + start + RETVAL=$? + ;; + condrestart|try-restart) + [ -f "$VAR_SUBSYS_KTUNE" ] || exit 0 + stop + start + RETVAL=$? + ;; + status) + status + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart|status}" + RETVAL=2 + ;; +esac diff --git a/tune-profiles/laptop-ac-powersave/ktune.sh b/tune-profiles/laptop-ac-powersave/ktune.sh index 67f5ce6..d13fc81 100644 --- a/tune-profiles/laptop-ac-powersave/ktune.sh +++ b/tune-profiles/laptop-ac-powersave/ktune.sh @@ -3,12 +3,72 @@ ALPM="medium_power" # Set ALPM for all host adapters that support it -for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do - hotplug="0" - if [ -e $x/sata_hotplug ]; then - hotplug="$(cat $x/sata_hotplug)" - fi - if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then - echo $ALPM > $x/link_power_management_policy - fi -done +set_alpm() { + for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do + hotplug="0" + if [ -e $x/sata_hotplug ]; then + hotplug="$(cat $x/sata_hotplug)" + fi + if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then + echo $1 > $x/link_power_management_policy + fi + done +} + +start() { + set_alpm ${ALPM} + return 0 +} + +# Disable ALPM for all host adapters that support it +stop() { + set_alpm "max_power" + return 0 +} + +# Reload it, just start once more +reload() { + start +} + +# Status +status() { + return 0 +} + + +case "$1" in + start) + [ -f "$VAR_SUBSYS_KTUNE" ] && exit 0 + start + RETVAL=$? + ;; + stop) + [ -f "$VAR_SUBSYS_KTUNE" ] || exit 0 + stop + RETVAL=$? + ;; + reload) + [ -f "$VAR_SUBSYS_KTUNE" ] && reload + RETVAL=$? + ;; + restart|force-reload) + [ -f "$VAR_SUBSYS_KTUNE" ] && stop + start + RETVAL=$? + ;; + condrestart|try-restart) + [ -f "$VAR_SUBSYS_KTUNE" ] || exit 0 + stop + start + RETVAL=$? + ;; + status) + status + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart|status}" + RETVAL=2 + ;; +esac diff --git a/tune-profiles/laptop-battery-powersave/ktune.sh b/tune-profiles/laptop-battery-powersave/ktune.sh index 096ab24..7cba09c 100644 --- a/tune-profiles/laptop-battery-powersave/ktune.sh +++ b/tune-profiles/laptop-battery-powersave/ktune.sh @@ -2,31 +2,104 @@ ALPM="min_power" -# Set ALPM for all host adapters that support it -for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do - hotplug="0" - if [ -e $x/sata_hotplug ]; then - hotplug="$(cat $x/sata_hotplug)" - fi - if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then - echo $ALPM > $x/link_power_management_policy - fi -done +set_alpm() { + for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do + hotplug="0" + if [ -e $x/sata_hotplug ]; then + hotplug="$(cat $x/sata_hotplug)" + fi + if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then + echo $1 > $x/link_power_management_policy + fi + done +} -# Enables USB autosuspend for all devices -for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done +start() { + # Set ALPM for all host adapters that support it + set_alpm ${ALPM} -# Enables multi core power savings for low wakeup systems -[ -e /sys/devices/system/cpu/sched_mc_power_savings ] && echo 1 > /sys/devices/system/cpu/sched_mc_power_savings + # Enables USB autosuspend for all devices + for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done -# Enable ondemand governor (best for powersaving) -[ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ] && echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + # Enables multi core power savings for low wakeup systems + [ -e /sys/devices/system/cpu/sched_mc_power_savings ] && echo 1 > /sys/devices/system/cpu/sched_mc_power_savings -# Enable AC97 audio power saving -[ -e /sys/module/snd_ac97_codec/parameters/power_save ] && echo Y > /sys/module/snd_ac97_codec/parameters/power_save + # Enable ondemand governor (best for powersaving) + [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ] && echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor -# Disable HAL polling of CDROMS -for i in /dev/scd*; do hal-disable-polling --device $i; done + # Enable AC97 audio power saving + [ -e /sys/module/snd_ac97_codec/parameters/power_save ] && echo Y > /sys/module/snd_ac97_codec/parameters/power_save -# Enable power saving mode for Wi-Fi cards -for i in /sys/bus/pci/devices/*/power_level ; do echo 5 > $i ; done + # Disable HAL polling of CDROMS + for i in /dev/scd*; do hal-disable-polling --device $i; done + + # Enable power saving mode for Wi-Fi cards + for i in /sys/bus/pci/devices/*/power_level ; do echo 5 > $i ; done + + return 0 +} + +stop() { + set_alpm "max_power" + + # Disables USB autosuspend for all devices + for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 0 > $i; done + + # Disables multi core power savings for low wakeup systems + [ -e /sys/devices/system/cpu/sched_mc_power_savings ] && echo 0 > /sys/devices/system/cpu/sched_mc_power_savings + + # Enable ondemand governor (best for powersaving) + [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ] && echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor + + # Enable AC97 audio power saving + [ -e /sys/module/snd_ac97_codec/parameters/power_save ] && echo Y > /sys/module/snd_ac97_codec/parameters/power_save + + # Reset power saving mode for Wi-Fi cards + for i in /sys/bus/pci/devices/*/power_level ; do echo 0 > $i ; done + + return 0 +} + +reload() { + start +} + +status() { + return 0 +} + +case "$1" in + start) + [ -f "$VAR_SUBSYS_KTUNE" ] && exit 0 + start + RETVAL=$? + ;; + stop) + [ -f "$VAR_SUBSYS_KTUNE" ] || exit 0 + stop + RETVAL=$? + ;; + reload) + [ -f "$VAR_SUBSYS_KTUNE" ] && reload + RETVAL=$? + ;; + restart|force-reload) + [ -f "$VAR_SUBSYS_KTUNE" ] && stop + start + RETVAL=$? + ;; + condrestart|try-restart) + [ -f "$VAR_SUBSYS_KTUNE" ] || exit 0 + stop + start + RETVAL=$? + ;; + status) + status + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart|status}" + RETVAL=2 + ;; +esac diff --git a/tune-profiles/server-powersave/ktune.sh b/tune-profiles/server-powersave/ktune.sh index 67f5ce6..d13fc81 100644 --- a/tune-profiles/server-powersave/ktune.sh +++ b/tune-profiles/server-powersave/ktune.sh @@ -3,12 +3,72 @@ ALPM="medium_power" # Set ALPM for all host adapters that support it -for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do - hotplug="0" - if [ -e $x/sata_hotplug ]; then - hotplug="$(cat $x/sata_hotplug)" - fi - if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then - echo $ALPM > $x/link_power_management_policy - fi -done +set_alpm() { + for x in /sys/bus/scsi/devices/host*/scsi_host/host*/; do + hotplug="0" + if [ -e $x/sata_hotplug ]; then + hotplug="$(cat $x/sata_hotplug)" + fi + if [ "$hotplug" == "0" -a -e $x/link_power_management_policy ]; then + echo $1 > $x/link_power_management_policy + fi + done +} + +start() { + set_alpm ${ALPM} + return 0 +} + +# Disable ALPM for all host adapters that support it +stop() { + set_alpm "max_power" + return 0 +} + +# Reload it, just start once more +reload() { + start +} + +# Status +status() { + return 0 +} + + +case "$1" in + start) + [ -f "$VAR_SUBSYS_KTUNE" ] && exit 0 + start + RETVAL=$? + ;; + stop) + [ -f "$VAR_SUBSYS_KTUNE" ] || exit 0 + stop + RETVAL=$? + ;; + reload) + [ -f "$VAR_SUBSYS_KTUNE" ] && reload + RETVAL=$? + ;; + restart|force-reload) + [ -f "$VAR_SUBSYS_KTUNE" ] && stop + start + RETVAL=$? + ;; + condrestart|try-restart) + [ -f "$VAR_SUBSYS_KTUNE" ] || exit 0 + stop + start + RETVAL=$? + ;; + status) + status + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|restart|condrestart|status}" + RETVAL=2 + ;; +esac diff --git a/tuned.spec b/tuned.spec index 892e811..b965ef6 100644 --- a/tuned.spec +++ b/tuned.spec @@ -1,6 +1,6 @@ Summary: A dynamic adaptive system tuning daemon Name: tuned -Version: 0.2.1 +Version: 0.2.2 Release: 1%{?dist} License: GPLv2+ Group: System Environment/Daemons @@ -96,6 +96,10 @@ fi %changelog +* Fri Aug 14 2009 Phil Knirsch 0.2.2-1 +- Updates to the ktune scripts +- Added support for start/stop of the ktune scripts and ktune initscript + * Tue Aug 04 2009 Phil Knirsch - 0.2.1-1 - Added first set of profiles - Added tuned-adm tool for profile switching