Skip to content

Commit dad7835

Browse files
committed
Better error message in case cpefreq is not available
1 parent 41c6de7 commit dad7835

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

script/set-cpu-frequency/customize.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ def preprocess(i):
1313
if shutil.which('cpupower') is None:
1414
return {'return': 1, 'error': "'cpupower' utility not found. Please install it (e.g., 'sudo apt install linux-tools-common linux-tools-generic' on Ubuntu, 'sudo dnf install kernel-tools' on Fedora/RHEL)."}
1515

16+
# Check that cpufreq is available on this system
17+
driver_file = '/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver'
18+
if not os.path.exists(driver_file):
19+
return {'return': 1, 'error': f"cpufreq not available on this system ({driver_file} does not exist). This can happen in VMs, containers, or if the kernel lacks cpufreq support."}
20+
1621
freq = env.get('MLC_TARGET_FREQ', '').strip()
1722
if freq != '':
1823
try:

0 commit comments

Comments
 (0)