def set_pstate_frequency(min_freq = 2500, max_freq = 2500):
CPU_FREQ_BASE_DIR = "/sys/devices/system/cpu"
CPU_FREQ_FILES = ["scaling_min_freq", "scaling_max_freq", "scaling_cur_freq"]
cpu_dirs = [f for f in os.listdir(CPU_FREQ_BASE_DIR) if re.match(r"cpu[0-9]+", f)]
for cpu_dir in cpu_dirs:
full_path = os.path.join(CPU_FREQ_BASE_DIR, cpu_dir, "cpufreq")
freq_paths = [os.path.join(full_path, x) for x in CPU_FREQ_FILES]
all_exist = True
After Change
def set_pstate_frequency(min_freq = 2500, max_freq = 2500):
CPU_FREQ_BASE_DIR = "/sys/devices/system/cpu"
CPU_FREQ_FILES = ["scaling_min_freq", "scaling_max_freq", "scaling_cur_freq"]
cpu_dirs = ["cpu" + str(cpu[0]) for cpu in parse_lscpu_cpu_core_list() if cpu[2]]
for cpu_dir in cpu_dirs:
full_path = os.path.join(CPU_FREQ_BASE_DIR, cpu_dir, "cpufreq")
freq_paths = [os.path.join(full_path, x) for x in CPU_FREQ_FILES]
all_exist = True