Refactored epb part, added doc for energy_perf_bias settings

This commit is contained in:
Anton Tamakhin 2024-09-08 10:26:05 +04:00
parent eccff01039
commit 9b86211024
4 changed files with 50 additions and 27 deletions

View File

@ -326,6 +326,14 @@ governor = performance
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = performance
# EPB (Energy Performance Bias) for the intel_pstate driver
# see conversion info: https://www.kernel.org/doc/html/latest/admin-guide/pm/intel_epb.html
# available EPB options include a numeric value between 0-15
# (where 0 = maximum performance and 15 = maximum power saving),
# or one of the following strings:
# performance (0), balance_performance (4), default (6), balance_power (8), or power (15)
# energy_perf_bias = balance_performance
# Platform Profiles
# https://www.kernel.org/doc/html/latest/userspace-api/sysfs-platform_profile.html
# See available options by running:
@ -356,6 +364,14 @@ governor = powersave
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = power
# EPB (Energy Performance Bias) for the intel_pstate driver
# see conversion info: https://www.kernel.org/doc/html/latest/admin-guide/pm/intel_epb.html
# available EPB options include a numeric value between 0-15
# (where 0 = maximum performance and 15 = maximum power saving),
# or one of the following strings:
# performance (0), balance_performance (4), default (6), balance_power (8), or power (15)
# energy_perf_bias = balance_power
# Platform Profiles
# https://www.kernel.org/doc/html/latest/userspace-api/sysfs-platform_profile.html
# See available options by running:

View File

@ -7,6 +7,14 @@ governor = performance
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = performance
# EPB (Energy Performance Bias) for the intel_pstate driver
# see conversion info: https://www.kernel.org/doc/html/latest/admin-guide/pm/intel_epb.html
# available EPB options include a numeric value between 0-15
# (where 0 = maximum performance and 15 = maximum power saving),
# or one of the following strings:
# performance (0), balance_performance (4), default (6), balance_power (8), or power (15)
# energy_perf_bias = balance_performance
# Platform Profiles
# https://www.kernel.org/doc/html/latest/userspace-api/sysfs-platform_profile.html
# See available options by running:
@ -48,6 +56,14 @@ governor = powersave
# EPP: see available preferences by running: cat /sys/devices/system/cpu/cpu0/cpufreq/energy_performance_available_preferences
energy_performance_preference = power
# EPB (Energy Performance Bias) for the intel_pstate driver
# see conversion info: https://www.kernel.org/doc/html/latest/admin-guide/pm/intel_epb.html
# available EPB options include a numeric value between 0-15
# (where 0 = maximum performance and 15 = maximum power saving),
# or one of the following strings:
# performance (0), balance_performance (4), default (6), balance_power (8), or power (15)
# energy_perf_bias = balance_power
# Platform Profiles
# https://www.kernel.org/doc/html/latest/userspace-api/sysfs-platform_profile.html
# See available options by running:

View File

@ -504,6 +504,18 @@ def set_platform_profile(conf, profile):
print(f'Setting to use: "{pp}" Platform Profile')
run(f"cpufreqctl.auto-cpufreq --pp --set={pp}", shell=True)
def set_energy_perf_bias(conf, profile):
if Path("/sys/devices/system/cpu/intel_pstate").exists() is False:
print('Not setting EPB (not supported by system)')
return
epb = "balance_performance" if profile == "charger" else "balance_power"
if conf.has_option(profile, "energy_perf_bias"):
epb = conf[profile]["energy_perf_bias"]
run(f"cpufreqctl.auto-cpufreq --epb --set={epb}", shell=True)
print(f'Setting to use: "{epb}" EPB')
def set_powersave():
conf = config.get_config()
gov = conf["battery"]["governor"] if conf.has_option("battery", "governor") else AVAILABLE_GOVERNORS_SORTED[-1]
@ -530,19 +542,8 @@ def set_powersave():
else:
run("cpufreqctl.auto-cpufreq --epp --set=balance_power", shell=True)
print('Setting to use: "balance_power" EPP')
if Path("/sys/devices/system/cpu/intel_pstate").exists():
if Path("/sys/devices/system/cpu/cpu0/power/energy_perf_bias").exists() is False:
print('Not setting EPB (not supported by system)')
else:
if conf.has_option("battery", "energy_perf_bias"):
epb = conf["battery"]["energy_perf_bias"]
run(f"cpufreqctl.auto-cpufreq --epb --set={epb}", shell=True)
print(f'Setting to use: "{epb}" EPB')
else:
run("cpufreqctl.auto-cpufreq --epb --set=balance-power", shell=True)
print('Setting to use: "balance-power" EPB')
set_energy_perf_bias(conf, "battery")
set_platform_profile(conf, "battery")
set_frequencies()
@ -629,17 +630,6 @@ def set_performance():
else:
run("cpufreqctl.auto-cpufreq --epp --set=balance_performance", shell=True)
print('Setting to use: "balance_performance" EPP')
if Path("/sys/devices/system/cpu/cpu0/power/energy_perf_bias").exists() is False:
print('Not setting EPB (not supported by system)')
else:
if conf.has_option("charger", "energy_perf_bias"):
epb = conf["charger"]["energy_perf_bias"]
run(f"cpufreqctl.auto-cpufreq --epb --set={epb}", shell=True)
print(f'Setting to use: "{epb}" EPB')
else:
run("cpufreqctl.auto-cpufreq --epb --set=default", shell=True)
print('Setting to use: "default" EPB')
elif Path("/sys/devices/system/cpu/amd_pstate").exists():
amd_pstate_status_path = "/sys/devices/system/cpu/amd_pstate/status"
@ -660,7 +650,8 @@ def set_performance():
else:
run("cpufreqctl.auto-cpufreq --epp --set=balance_performance", shell=True)
print('Setting to use: "balance_performance" EPP')
set_energy_perf_bias(conf, "charger")
set_platform_profile(conf, "charger")
set_frequencies()

View File

@ -269,9 +269,9 @@ function set_energy_performance_bias () {
else
case $VALUE in
performance) EPB_VALUE=0;;
balance-performance) EPB_VALUE=4;;
normal| default) EPB_VALUE=6;;
balance-power) EPB_VALUE=8;;
balance_performance) EPB_VALUE=4;;
default) EPB_VALUE=6;;
balance_power) EPB_VALUE=8;;
power) EPB_VALUE=15;;
*)
verbose "Invalid value provided for EPB"