~jocave/checkbox/hybrid-amd-gpu-mods

« back to all changes in this revision

Viewing changes to checkbox-old/scripts/cpu_offlining

  • Committer: Tarmac
  • Author(s): Brendan Donegan
  • Date: 2013-06-03 11:12:58 UTC
  • mfrom: (2154.2.1 bug1185759)
  • Revision ID: tarmac-20130603111258-1b3m5ydvkf1accts
"[r=zkrynicki][bug=1185759][author=brendan-donegan] automatic merge by tarmac"

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
 
 
3
echo "Beginning CPU Offlining Test" 1>&2
 
4
 
 
5
result=0
 
6
cpu_count=0
 
7
 
 
8
# Turn CPU cores off
 
9
for cpu_num in `ls /sys/devices/system/cpu | grep -o cpu[0-9]*`; do
 
10
    if [ -f /sys/devices/system/cpu/$cpu_num/online ]; then
 
11
        if [ "$cpu_num" != "cpu0" ]; then
 
12
            ((cpu_count++))
 
13
            echo "Offlining $cpu_num" 1>&2
 
14
            echo 0 > /sys/devices/system/cpu/$cpu_num/online
 
15
 
 
16
            grep -w -i -q $cpu_num /proc/interrupts
 
17
            if [ $? -eq 0 ]; then
 
18
                echo "ERROR: Failed to offline $cpu_num" 1>&2
 
19
                result=1
 
20
            fi
 
21
        fi
 
22
    fi
 
23
done
 
24
 
 
25
# Back on again
 
26
for cpu_num in `ls /sys/devices/system/cpu | grep -o cpu[0-9]*`; do
 
27
    if [ -f /sys/devices/system/cpu/$cpu_num/online ]; then
 
28
        if [ "$cpu_num" != "cpu0" ]; then        
 
29
            echo "Onlining $cpu_num" 1>&2
 
30
            echo 1 > /sys/devices/system/cpu/$cpu_num/online
 
31
            grep -w -i -q $cpu_num /proc/interrupts
 
32
            if [ $? -eq 1 ]; then
 
33
                echo "ERROR: Failed to online $cpu_num" 1>&2
 
34
                result=1
 
35
            fi
 
36
        fi
 
37
    fi
 
38
done
 
39
 
 
40
if [ $result -eq 0 ]; then
 
41
    echo "Successfully turned $cpu_count cores off and back on"
 
42
else
 
43
    echo "Error with offlining one or more cores." 1>&2
 
44
fi
 
45
 
 
46
exit $result