-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare_for_measurement.sh
executable file
·85 lines (75 loc) · 1.76 KB
/
prepare_for_measurement.sh
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
#!/bin/sh
#
# © 2023-2024 Nokia
# Licensed under the Apache License 2.0
# SPDX-License-Identifier: Apache-2.0
#
set -e -u
# Check cpufreq governor:
NEED_SET_GOV=""
for gov in $(cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor 2> /dev/null)
do
if [ "$gov" != "performance" ]; then
NEED_SET_GOV="1"
fi
done
if [ -z "$NEED_SET_GOV" ]; then
echo "OK, cpufreq governor is 'performance'."
fi
# Check SMT/hyperthreading control:
_SMTCTRL=$(cat /sys/devices/system/cpu/smt/control)
if [ "$_SMTCTRL" = "off" ] || [ "$_SMTCTRL" = "forceoff" ] || [ "$_SMTCTRL" = "notsupported" ]; then
NEED_SET_SMT=""
echo "OK, SMT/hyperthreading is off."
else
NEED_SET_SMT="1"
fi
# Check frequency boosting:
NEED_SET_IB=""
_intel_file="/sys/devices/system/cpu/intel_pstate/no_turbo"
NEED_SET_OB=""
_other_file="/sys/devices/system/cpu/cpufreq/boost"
if [ -e "$_intel_file" ]; then
# Intel CPU
if [ $(cat "$_intel_file") = "0" ]; then
NEED_SET_IB="1"
else
echo "OK, intel freq boost is off"
fi
else
# Other CPU
if [ $(cat "$_other_file") = "1" ]; then
NEED_SET_OB="1"
else
echo "OK, freq boost is off"
fi
fi
# Set cpufreq governor:
if [ -n "$NEED_SET_GOV" ]; then
set -x
sudo cpupower -c all frequency-set -g performance
set +x
fi
# Set SMT/hyperthreading control:
if [ -n "$NEED_SET_SMT" ]; then
set -x
echo "off" | sudo tee /sys/devices/system/cpu/smt/control
cat /sys/devices/system/cpu/smt/control
set +x
fi
# Set frequency boosting:
if [ -n "$NEED_SET_IB" ]; then
set -x
echo "1" | sudo tee "$_intel_file"
cat "$_intel_file"
set +x
fi
if [ -n "$NEED_SET_OB" ]; then
set -x
echo "0" | sudo tee "$_other_file"
cat "$_other_file"
set +x
fi
# Print temperature:
echo "Temperature:"
sensors "*-isa-*" | grep -e "CPU:" -e "Core"