Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "efficient cores only" on cpuhotplug plugin #206

Open
wants to merge 2 commits into
base: lmt-upstream
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions etc/laptop-mode/conf.d/cpuhotplug.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ CONTROL_CPU_HOTPLUG=0
# half -> disable half of available logical CPUs
# quarter -> disable 1/4 of available logical CPUs
# 3quarter -> disable 3/4 of available logical CPUs
# performance > disable all performance CPUs keeping online
# only the efficient cores + cpu0 + cpu1
#
# integer -> Set this to a user specific number
# list of cpu<integer>-s -> Disable specific CPUs. Example: "cpu1 cpu3"
Expand Down
28 changes: 28 additions & 0 deletions usr/share/laptop-mode-tools/modules/cpuhotplug
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,31 @@ get_cpus_from_ids() {
done
}

# Get the lowest max_freq of all cores, to retrieve what are the
# ecores(efficient cores) and only enable them + cpu0 and cpu1
get_cpus_from_lower_max_freq(){

# evaluating if cpuinfo_max_freq exists and
# using cpu0 as the sane default lower max_freq
if [ -f /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq ]; then
lowest_maxfreq=$(cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_max_freq| sort -u| head -1)
else
log "VERBOSE" "cpufreq modules not loaded. Can't proceed with finding lowest max frequency"
fi

# playing safe with kernel by not removing the first CPU and it's related HT
cpu_list=""

for cpu in /sys/devices/system/cpu/cpu[0-9]* ; do
current_freq=$(cat $cpu/cpufreq/cpuinfo_max_freq)
if [ $current_freq -gt $lowest_maxfreq ]; then
if [ $cpu != "/sys/devices/system/cpu/cpu0" ] && [ $cpu != "/sys/devices/system/cpu/cpu1" ]; then
cpu_list="$cpu_list $cpu"
fi
fi
done
}

# Get a list of cpus to control from DISABLE_AVAILABLE_CPU value.
get_cpus_to_control() {
num_cpu=`max_available_cpus`
Expand All @@ -60,6 +85,9 @@ get_cpus_to_control() {
"3quarter")
get_cpus_from_number $((num_cpu * 3/4))
;;
"performance")
get_cpus_from_lower_max_freq
;;
[0-9]*)
get_cpus_from_number $1
;;
Expand Down