1
0
Fork 0

Add support for controlling amd-pstate core performance boost

Core performance boost control is added to kernel 6.11.
This sets up the policy to turn it off while in the power saver profile.

Link: https://lore.kernel.org/linux-pm/1a78eeaa-fadd-4734-aaeb-2fe11e96e198@amd.com/T/#m4a0c8917ea8fb033504055bd61512c80c85410c8
This commit is contained in:
Mario Limonciello 2024-06-21 15:12:39 -05:00
parent 5d5dbfccf4
commit 068928e47b
4 changed files with 42 additions and 0 deletions

View file

@ -8,6 +8,7 @@ include=balanced
[cpu] [cpu]
energy_performance_preference=balance_power energy_performance_preference=balance_power
boost=1
[video] [video]
panel_power_savings=1 panel_power_savings=1

View file

@ -13,6 +13,7 @@ priority=10
governor=conservative|powersave governor=conservative|powersave
energy_perf_bias=normal energy_perf_bias=normal
energy_performance_preference=balance_performance energy_performance_preference=balance_performance
boost=1
[acpi] [acpi]
platform_profile=balanced platform_profile=balanced

View file

@ -9,6 +9,7 @@ summary=Optimize for low power consumption
governor=ondemand|powersave governor=ondemand|powersave
energy_perf_bias=powersave|power energy_perf_bias=powersave|power
energy_performance_preference=power energy_performance_preference=power
boost=0
[acpi] [acpi]
platform_profile=low-power|quiet platform_profile=low-power|quiet

View file

@ -186,6 +186,10 @@ class CPULatencyPlugin(hotplug.Plugin):
pm_qos_resume_latency_us=100 pm_qos_resume_latency_us=100
---- ----
Allows any C-state with a resume latency less than value. Allows any C-state with a resume latency less than value.
[cpu]
boost=1
----
CPU is allowed to boost above nominal frequencies for short periods of time.
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
@ -237,6 +241,7 @@ class CPULatencyPlugin(hotplug.Plugin):
"no_turbo" : None, "no_turbo" : None,
"pm_qos_resume_latency_us": None, "pm_qos_resume_latency_us": None,
"energy_performance_preference" : None, "energy_performance_preference" : None,
"boost": None,
} }
def _check_arch(self): def _check_arch(self):
@ -603,6 +608,9 @@ class CPULatencyPlugin(hotplug.Plugin):
return_err = True) return_err = True)
return (retcode, err_msg) return (retcode, err_msg)
def _pstate_boost_path(self, cpu_id):
return "/sys/devices/system/cpu/cpufreq/policy%s/boost" % cpu_id
def _pstate_preference_path(self, cpu_id, available = False): def _pstate_preference_path(self, cpu_id, available = False):
return "/sys/devices/system/cpu/cpufreq/policy%s/energy_performance_%s" % (cpu_id, "available_preferences" if available else "preference") return "/sys/devices/system/cpu/cpufreq/policy%s/energy_performance_%s" % (cpu_id, "available_preferences" if available else "preference")
@ -748,6 +756,37 @@ class CPULatencyPlugin(hotplug.Plugin):
return None return None
return self._cmd.read_file(self._pm_qos_resume_latency_us_path(device), no_error=ignore_missing).strip() return self._cmd.read_file(self._pm_qos_resume_latency_us_path(device), no_error=ignore_missing).strip()
@command_set("boost", per_device=True)
def _set_boost(self, boost, device, sim, remove):
if not self._is_cpu_online(device):
log.debug("%s is not online, skipping" % device)
return None
cpu_id = device.lstrip("cpu")
if os.path.exists(self._pstate_boost_path(cpu_id)):
if not sim:
if boost == "0" or boost == "1":
self._cmd.write_to_file(self._pstate_boost_path(cpu_id), boost, \
no_error = [errno.ENOENT] if remove else False, ignore_same=True)
log.info("Setting boost value '%s' for cpu '%s'" % (boost, device))
else:
log.error("Failed to set boost on cpu '%s'. Is the value in the profile correct?" % device)
return str(boost)
else:
log.debug("boost file missing, which can happen on pre 6.11 kernels.")
return None
@command_get("boost")
def _get_boost(self, device, ignore_missing=False):
if not self._is_cpu_online(device):
log.debug("%s is not online, skipping" % device)
return None
cpu_id = device.lstrip("cpu")
if os.path.exists(self._pstate_boost_path(cpu_id)):
return self._cmd.read_file(self._pstate_boost_path(cpu_id)).strip()
else:
log.debug("boost file missing, which can happen on pre 6.11 kernels.")
return None
@command_set("energy_performance_preference", per_device=True) @command_set("energy_performance_preference", per_device=True)
def _set_energy_performance_preference(self, energy_performance_preference, device, sim, remove): def _set_energy_performance_preference(self, energy_performance_preference, device, sim, remove):
if not self._is_cpu_online(device): if not self._is_cpu_online(device):