#!/bin/bash # TeknoHog's cpufreq script for Linux 2.6 # Written for a Pentium M Dothan 725, but it should work for any CPU # whose frequency can be adjusted by the Linux 2.6 driver. # The userspace portion with fixed frequencies may have to be adjusted # per CPU model. function od_finetune() { cd ondemand # these two are load limits in percentage: # if load is below this, slow down cpu #echo 70 > down_threshold # if load is over this, speed up cpu #echo 90 > up_threshold #cat sampling_rate_min > sampling_rate #echo 1 > sampling_down_factor echo 0 > ignore_nice_load #echo 100000 > sampling_rate cd .. } function c_finetune() { cd conservative # these two are load limits in percentage: # if load is below this, slow down cpu echo 70 > down_threshold # if load is over this, speed up cpu echo 90 > up_threshold echo 1 > ignore_nice_load # percent of max freq, for me it's actually 12.5 echo 15 > freq_step echo 1 > sampling_down_factor # samping_rates are actually timeslice lengths in microseconds, # so minimum gives fastest transitions (duh!) #cat sampling_rate_min > sampling_rate # The default seems to change between kernels. 1e5 was the default for # some time before 2.6.30, the new shorter one is noisier echo 100000 > sampling_rate cd .. } function usage() { echo "Usage: `basename $0` OPTION where OPTION is one of the following: max or min (should be obvious) c Conservative: increase/decrease clockspeed smoothly as needed od Ondemand: More aggressive than conservative (number) Fixed clockspeed in integral multiples of 100 MHz" } cd /sys/devices/system/cpu/cpu0/cpufreq case "$1" in perf|max) echo performance > scaling_governor ;; quiet|min) echo powersave > scaling_governor ;; [0-9]|[0-9][0-9]) echo userspace > scaling_governor echo "$1"00000 > scaling_setspeed ;; od) echo ondemand > scaling_governor od_finetune ;; c) echo conservative > scaling_governor c_finetune ;; -h|--help) usage echo ;; *) cd stats for file in *; do echo $file: cat $file echo done cd .. ;; esac readfreq=`cat scaling_cur_freq` governor=`cat scaling_governor` echo frequency: $readfreq kHz echo governor: $governor