@@ -5,6 +5,14 @@ shopt -s extglob
5
5
6
6
declare -A core_ids
7
7
8
+ # Learn all efficency cores if they exist
9
+ cpu_list=()
10
+ if [ -f /sys/devices/cpu_atom/cpus ]; then
11
+ range=" $( cat /sys/devices/cpu_atom/cpus) "
12
+ IFS=' -' read -r start end <<< " $range"
13
+ cpu_list=($( eval echo {$start ..$end }) )
14
+ fi
15
+
8
16
# shellcheck disable=SC2012
9
17
for cpu in $( ls -1d /sys/devices/system/cpu/cpu* | sort --version-sort) ; do
10
18
[[ $( basename $cpu ) =~ ^cpu[0-9]+$ ]] || continue
@@ -32,14 +40,28 @@ for cpu in $(ls -1d /sys/devices/system/cpu/cpu* | sort --version-sort) ; do
32
40
chmod a-w $cpu /cpufreq/scaling_{max,min}_freq
33
41
fi
34
42
35
- # Disable all but one thread on each core. Both core_id and physical_package_id are
36
- # numbers it must be ensured that for the following examples are seen as distinct:
43
+ # Disable all but one thread on each core per socket . Both core_id and physical_package_id
44
+ # are numbers so it must be ensured that for the following examples are seen as distinct:
37
45
# - core_id=1, physical_package=11
38
- # - core_id=11, physycal_package =1
46
+ # - core_id=11, physical_package =1
39
47
# Simple concatenation would result in the string '111' for both cores. Though `cat`
40
48
# adds a newline after each file, we do not want to rely on `cat` to always add this
41
49
# 'delimiter'.
42
50
core_id=$( cat $cpu /topology/core_id | tr -d ' \n' ) ' -' $( cat $cpu /topology/physical_package_id | tr -d ' \n' )
51
+
52
+ # Disable all efficiency cores
53
+ found=0
54
+ for efficiency_core in " ${cpu_list[@]} " ; do
55
+ if [[ " $cpu " == " /sys/devices/system/cpu/cpu$efficiency_core " ]]; then
56
+ echo 0 > $cpu /online
57
+ found=1
58
+ break
59
+ fi
60
+ done
61
+ if [ " $found " -eq " 1" ]; then
62
+ continue
63
+ fi
64
+
43
65
if [[ ${core_ids[$core_id]:- } ]]; then
44
66
echo 0 > $cpu /online
45
67
else
0 commit comments