3 # Cycle the CPUs through various frequencies.
5 # Copyright (C) 2003-2006 IBM
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of the
10 # License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23 # Do any CPU support cpufreq?
24 CPUFREQ_ENABLED_CPUS
=`/bin/ls -lad /sys/devices/system/cpu/cpu*/cpufreq 2> /dev/null | wc -l`
26 if [ "$CPUFREQ_ENABLED_CPUS" -lt 1 ]; then
27 echo "None of your CPUs support cpufreq. Bye."
31 # Turn on acpi_pstate_strict to ensure that state transitions actually happen...
32 if [ -f /sys
/module
/acpi_cpufreq
/parameters
/acpi_pstate_strict
]; then
33 echo 1 > /sys
/module
/acpi_cpufreq
/parameters
/acpi_pstate_strict
35 if [ -f /sys
/module
/acpi
/parameters
/acpi_pstate_strict
]; then
36 echo 1 > /sys
/module
/acpi
/parameters
/acpi_pstate_strict
39 # First, knock off any powersaving daemons...
40 for i
in `ls /etc/init.d/*powernow /etc/init.d/*cpuspeed* /etc/init.d/*powersave* 2> /dev/null`; do
44 # Ensure that we have the userspace governor running
45 for i
in /sys
/devices
/system
/cpu
/cpu
*; do
46 echo userspace
> "$i/cpufreq/scaling_governor"
50 trap 'kill -9 `pgrep -P $$` `pgrep cpufreq.bin` 2> /dev/null; exit 0' 1 2 15
52 # Did we see any failures?
54 OLD_ERRORS
=`egrep -ic "(error|fail|invalid|denied|cannot)" $LOGFILE`
56 # For all CPUs with cpufreq: remove CPUs that are locked with another.
57 function find_cpufreq_cpus
() {
58 for cpu
in `ls -d /sys/devices/system/cpu/cpu*/cpufreq 2> /dev/null`; do
59 # Locked CPUs are done with symlinks in 2.6.14.
60 if [ -L "$cpu" ]; then
64 CPU_NUM
=`dirname $cpu | sed -e 's/.*cpu//g'`
65 MATCHES
=`(cat /sys/devices/system/cpu/cpu*/cpufreq/affected_cpus /dev/null 2> /dev/null | while read car cdr; do echo $cdr; done) | grep "^$CPU_NUM$" -c`
66 if [ $MATCHES -eq 0 ]; then
72 # Find the frequencies for a given CPU
73 function find_cpu_frequencies
() {
74 i
="/sys/devices/system/cpu/cpu$1"
76 if [ -f "$i/cpufreq/scaling_available_frequencies" ]; then
77 cat "$i/cpufreq/scaling_available_frequencies"
79 cat "$i/cpufreq/scaling_min_freq" "$i/cpufreq/scaling_max_freq"
83 # Figure out which CPUs have cpufreq support.
84 find_cpufreq_cpus |
while read f
; do
85 echo Starting CPU frequency testing on CPU
$f
86 i
=/sys
/devices
/system
/cpu
/cpu
$f
88 # Does this CPU have cpufreq?
89 if [ ! -d "$i/cpufreq/" ]; then
94 "$POUNDER_HOME/timed_loop" 900 "$POUNDER_SRCDIR/cpufreq/cpufreq.bin" "$i/cpufreq/scaling_setspeed" 10000 $f `find_cpu_frequencies $f` &
97 # Wait for this to finish
98 while [ `pgrep cpufreq.bin | wc -l` -gt 0 ]; do
102 # Did we see any failures?
103 NEW_ERRORS
=`egrep -ic "(error|fail|invalid|denied|cannot)" $LOGFILE`
104 ERRORS
=$
(( NEW_ERRORS
- OLD_ERRORS
))
105 if [ $ERRORS -eq 255 ]; then
109 # Failures will show up in the test output. Or better yet,
110 # panic/oops/BUG the machine.