Add support for configuring/overriding "Energy Performance Preference (EPP)" (#619)

* Added support for configuring/overriding energy performance preference (EPP)

* Corrected path to print available energy performance preferences in docs

* Added "EPP" wording to config examples

* Added message when EPP is not supported
This commit is contained in:
Murray Gervais 2023-12-28 23:11:27 -08:00 committed by GitHub
parent 8938cc92d7
commit fe29620646
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 4 deletions

View File

@ -286,6 +286,9 @@ By default, auto-cpufreq does not use the config file! If you wish to use it, th
# preferred governor
governor = performance
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = performance
# minimum cpu frequency (in kHz)
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
@ -307,6 +310,9 @@ turbo = auto
# preferred governor
governor = powersave
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = power
# minimum cpu frequency (in kHz)
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html

View File

@ -4,6 +4,9 @@
# preferred governor.
governor = performance
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = performance
# minimum cpu frequency (in kHz)
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html
@ -25,6 +28,9 @@ turbo = auto
# preferred governor
governor = powersave
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = power
# minimum cpu frequency (in kHz)
# example: for 800 MHz = 800000 kHz --> scaling_min_freq = 800000
# see conversion info: https://www.rapidtables.com/convert/frequency/mhz-to-hz.html

View File

@ -676,8 +676,15 @@ def set_powersave():
Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists()
and Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() is False
):
run("cpufreqctl.auto-cpufreq --epp --set=balance_power", shell=True)
print('Setting to use: "balance_power" EPP')
if conf.has_option("battery", "energy_performance_preference"):
epp = conf["battery"]["energy_performance_preference"]
run(f"cpufreqctl.auto-cpufreq --epp --set={epp}", shell=True)
print(f'Setting to use: "{epp}" EPP')
else:
run("cpufreqctl.auto-cpufreq --epp --set=balance_power", shell=True)
print('Setting to use: "balance_power" EPP')
else:
print('Not setting EPP (not supported by system)')
# set frequencies
set_frequencies()
@ -887,8 +894,15 @@ def set_performance():
Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists()
and Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() is False
):
run("cpufreqctl.auto-cpufreq --epp --set=balance_performance", shell=True)
print('Setting to use: "balance_performance" EPP')
if conf.has_option("charger", "energy_performance_preference"):
epp = conf["charger"]["energy_performance_preference"]
run(f"cpufreqctl.auto-cpufreq --epp --set={epp}", shell=True)
print(f'Setting to use: "{epp}" EPP')
else:
run("cpufreqctl.auto-cpufreq --epp --set=balance_performance", shell=True)
print('Setting to use: "balance_performance" EPP')
else:
print('Not setting EPP (not supported by system)')
# set frequencies
set_frequencies()