Skip to content

Commit

Permalink
Add support for configuring/overriding "Energy Performance Preference…
Browse files Browse the repository at this point in the history
… (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
  • Loading branch information
murbot committed Dec 29, 2023
1 parent 8938cc9 commit fe29620
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions auto-cpufreq.conf-example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 18 additions & 4 deletions auto_cpufreq/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit fe29620

Please sign in to comment.