-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathck-set-cpu-online-and-frequency
More file actions
executable file
·95 lines (76 loc) · 2.16 KB
/
Copy pathck-set-cpu-online-and-frequency
File metadata and controls
executable file
·95 lines (76 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#! /bin/bash
#
# Collective Knowledge (CK)
#
# See CK LICENSE.txt for licensing details.
# See CK COPYRIGHT.txt for copyright details.
#
# Developer: Grigori Fursin
#
governer=conservative
if [ "$CK_CPU_FREQ_GOVERNOR" != "" ]; then
governer=$CK_CPU_FREQ_GOVERNOR
fi
freqmin=cpuinfo_min_freq
freqmax=cpuinfo_max_freq
if [ "$CK_CPU_FREQ_FILE" != "" ]; then
freqmin=$CK_CPU_FREQ_FILE
freqmax=$CK_CPU_FREQ_FILE
fi
if [ "$CK_CPU_FREQ" != "" ]; then
freqmin=$CK_CPU_FREQ
freqmax=$CK_CPU_FREQ
fi
if [ "$CK_CPU_FREQ_MIN" != "" ]; then
freqmin="$CK_CPU_FREQ_MIN"
fi
if [ "$CK_CPU_FREQ_MAX" != "" ]; then
freqmax="$CK_CPU_FREQ_MAX"
fi
if [ "$1" != "" ]; then
freqmin="$1"
freqmax="$1"
fi
if [ "$2" != "" ]; then
freqmax="$2"
fi
online=1
if [ "$CK_CPU_ONLINE" != "" ]; then
online=$CK_CPU_ONLINE
fi
if [ "$online" == "1" ] ; then
echo " Bringing all CPU online ..."
for cpudir in /sys/devices/system/cpu/cpu*
do
if [ -f "$cpudir/online" ] ; then
echo $online | sudo tee $cpudir/online >/dev/null
fi
done
fi
for cpudir in /sys/devices/system/cpu/cpu*
do
if [ -d "$cpudir/cpufreq" ] && [ -f "$cpudir/cpufreq/scaling_governor" ] ; then
echo "*** Processing $cpudir ..."
echo " Setting $governer state ..."
echo $governer | sudo tee $cpudir/cpufreq/scaling_governor >/dev/null
# change $freqmin and $freqmax in a subshell
(
if ! [[ $freqmin =~ [0-9]+ ]]; then
freqmin=$(cat $cpudir/cpufreq/$freqmin)
fi
if ! [[ $freqmax =~ [0-9]+ ]]; then
freqmax=$(cat $cpudir/cpufreq/$freqmax)
fi
echo " Setting min/max frequency=$freqmin/$freqmax ..."
echo $freqmin | sudo tee $cpudir/cpufreq/scaling_min_freq >/dev/null
echo $freqmax | sudo tee $cpudir/cpufreq/scaling_max_freq >/dev/null
echo $freqmin | sudo tee $cpudir/cpufreq/scaling_min_freq >/dev/null
echo $freqmax | sudo tee $cpudir/cpufreq/scaling_max_freq >/dev/null
)
echo " Current frequency=$(cat $cpudir/cpufreq/scaling_cur_freq)"
if [ "$online" == "0" -a "$cpudir" != "/sys/devices/system/cpu/cpu0" ]; then
echo " Bringing CPU offline ..."
echo $online | sudo tee $cpudir/online >/dev/null
fi
fi
done