@@ -5,6 +5,14 @@ shopt -s extglob
55
66declare -A core_ids
77
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+
816# shellcheck disable=SC2012
917for cpu in $( ls -1d /sys/devices/system/cpu/cpu* | sort --version-sort) ; do
1018 [[ $( basename $cpu ) =~ ^cpu[0-9]+$ ]] || continue
@@ -32,14 +40,28 @@ for cpu in $(ls -1d /sys/devices/system/cpu/cpu* | sort --version-sort) ; do
3240 chmod a-w $cpu /cpufreq/scaling_{max,min}_freq
3341 fi
3442
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:
3745 # - core_id=1, physical_package=11
38- # - core_id=11, physycal_package =1
46+ # - core_id=11, physical_package =1
3947 # Simple concatenation would result in the string '111' for both cores. Though `cat`
4048 # adds a newline after each file, we do not want to rely on `cat` to always add this
4149 # 'delimiter'.
4250 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+
4365 if [[ ${core_ids[$core_id]:- } ]]; then
4466 echo 0 > $cpu /online
4567 else
0 commit comments