def get_pstate_frequency():
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)]
output = dict()
for cpu_dir in cpu_dirs:
full_path = os.path.join(CPU_FREQ_BASE_DIR, cpu_dir, "cpufreq")
After Change
def get_pstate_frequency():
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]]
output = dict()
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]