Skip to content

Commit accc43d

Browse files
committed
Store the isolated cores for ansible
A bit of defence in depth as this would make that we don't allow the kernel to schedule work before disabling. This should make that the disabling has a lower change of failing.
1 parent e2c48e3 commit accc43d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

provision-contest/disable-turboboost_ht

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -eu -o pipefail
44
shopt -s extglob
55

66
declare -A core_ids
7+
declare -A disabled_cores
78

89
# Learn all efficency cores if they exist
910
cpu_list=()
@@ -13,6 +14,14 @@ if [ -f /sys/devices/cpu_atom/cpus ]; then
1314
cpu_list=($(eval echo {$start..$end}))
1415
fi
1516

17+
disable_cpu () {
18+
cpu="$1"
19+
echo 0 > $cpu/online
20+
disabled_cores+=("${cpu##*/}")
21+
}
22+
23+
store_isolcpus_fact="/var/tmp/isolcpus"
24+
1625
# shellcheck disable=SC2012
1726
for cpu in $(ls -1d /sys/devices/system/cpu/cpu* | sort --version-sort) ; do
1827
[[ $(basename $cpu) =~ ^cpu[0-9]+$ ]] || continue
@@ -53,7 +62,7 @@ for cpu in $(ls -1d /sys/devices/system/cpu/cpu* | sort --version-sort) ; do
5362
found=0
5463
for efficiency_core in "${cpu_list[@]}"; do
5564
if [[ "$cpu" == "/sys/devices/system/cpu/cpu$efficiency_core" ]]; then
56-
echo 0 > $cpu/online
65+
disable_cpu $cpu
5766
found=1
5867
break
5968
fi
@@ -63,7 +72,7 @@ for cpu in $(ls -1d /sys/devices/system/cpu/cpu* | sort --version-sort) ; do
6372
fi
6473

6574
if [[ ${core_ids[$core_id]:-} ]]; then
66-
echo 0 > $cpu/online
75+
disable_cpu $cpu
6776
else
6877
core_ids[$core_id]=1
6978
fi
@@ -94,3 +103,8 @@ elif [ -d $DIR_AMD ]; then
94103
else
95104
echo "Warning: kernel (turbo) boost config not found in '$DIR_INTEL' or '$DIR_AMD'."
96105
fi
106+
107+
if [ -n "${store_isolcpus_fact}" ]; then
108+
csv_string=$(IFS=, ; echo "${disabled_cores[*]}")
109+
echo "$csv_string" > "$store_isolcpus_fact"
110+
fi

0 commit comments

Comments
 (0)