From 27d462ac5e270f42be47e60c43169fd6601c7891 Mon Sep 17 00:00:00 2001 From: "Rick Poyner (rico)" Date: Fri, 28 Jun 2024 20:58:01 -0400 Subject: [PATCH] [tools] Permit benchmark experiments without boost control (#21640) Contemporary AMD processors have a frequency boost feature, called "Precision Boost". Sadly, the Linux kernel driver configuration as of Ubuntu Jammy + Linux 6.5 does not expose boost control. Some user land control does appear to be promised for future kernels. In the mean time, this patch permits benchmark experiments to run, but prints a console warning that results may be noisy. --- tools/performance/benchmark_tool.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/performance/benchmark_tool.py b/tools/performance/benchmark_tool.py index 760bf39c2410..9792dce0a2e6 100644 --- a/tools/performance/benchmark_tool.py +++ b/tools/performance/benchmark_tool.py @@ -70,6 +70,20 @@ def sudo(*args, quiet=False): subprocess.run(new_args, stderr=subprocess.STDOUT, check=True) +class NoBoost: + def is_supported(self): + return True + + def get_boost(self): + """Return the current boost state; True means boost is enabled.""" + return False + + def set_boost(self, boost_value): + """Set the boost state; True means boost is enabled.""" + say("No method of cpu boost control was found;" + " nothing is changed. Benchmark results may be noisy.") + + class IntelBoost: # This is the Linux kernel configuration file for Intel's "turbo boost". # https://www.kernel.org/doc/html/v4.12/admin-guide/pm/intel_pstate.html#no-turbo-attr @@ -114,7 +128,7 @@ class CpuSpeedSettings: """Routines for controlling CPU speed.""" def __init__(self): self._boost = None - for boost in [LinuxKernelBoost, IntelBoost]: + for boost in [LinuxKernelBoost, IntelBoost, NoBoost]: if boost().is_supported(): self._boost = boost()