From 279251bf3a1541480ea7244c0453f2961c450471 Mon Sep 17 00:00:00 2001 From: PhoenixCausesOof Date: Tue, 23 Jan 2024 12:05:10 -0300 Subject: [PATCH 1/3] Fix dynamic boosting being incorrectly diagnosed --- auto_cpufreq/core.py | 66 ++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index 6b3b5724..f388865e 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -672,19 +672,28 @@ def set_powersave(): if get_override() != "default": print("Warning: governor overwritten using `--force` flag.") run(f"cpufreqctl.auto-cpufreq --governor --set={gov}", shell=True) - if ( - Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() - and Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() is False - ): - if conf.has_option("battery", "energy_performance_preference"): - epp = conf["battery"]["energy_performance_preference"] - run(f"cpufreqctl.auto-cpufreq --epp --set={epp}", shell=True) - print(f'Setting to use: "{epp}" EPP') - else: - run("cpufreqctl.auto-cpufreq --epp --set=balance_power", shell=True) - print('Setting to use: "balance_power" EPP') - else: + + + if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() is false: print('Not setting EPP (not supported by system)') + else: + dynboost_enabled = Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() + + if dynboost_enabled: + dynboost_enabled = bool(int( + os.popen("cat /sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").read() + )) + + if dynboost_enabled: + print('Not setting EPP (dynamic boosting is enabled)') + else: + if conf.has_option("battery", "energy_performance_preference"): + epp = conf["battery"]["energy_performance_preference"] + run(f"cpufreqctl.auto-cpufreq --epp --set={epp}", shell=True) + print(f'Setting to use: "{epp}" EPP') + else: + run("cpufreqctl.auto-cpufreq --epp --set=balance_power", shell=True) + print('Setting to use: "balance_power" EPP') # set frequencies set_frequencies() @@ -890,19 +899,28 @@ def set_performance(): f"cpufreqctl.auto-cpufreq --governor --set={gov}", shell=True, ) - if ( - Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() - and Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() is False - ): - if conf.has_option("charger", "energy_performance_preference"): - epp = conf["charger"]["energy_performance_preference"] - run(f"cpufreqctl.auto-cpufreq --epp --set={epp}", shell=True) - print(f'Setting to use: "{epp}" EPP') - else: - run("cpufreqctl.auto-cpufreq --epp --set=balance_performance", shell=True) - print('Setting to use: "balance_performance" EPP') - else: + + + if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() is false: print('Not setting EPP (not supported by system)') + else: + dynboost_enabled = Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() + + if dynboost_enabled: + dynboost_enabled = bool(int( + os.popen("cat /sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").read() + )) + + if dynboost_enabled: + print('Not setting EPP (dynamic boosting is enabled)') + else: + if conf.has_option("charger", "energy_performance_preference"): + epp = conf["charger"]["energy_performance_preference"] + run(f"cpufreqctl.auto-cpufreq --epp --set={epp}", shell=True) + print(f'Setting to use: "{epp}" EPP') + else: + run("cpufreqctl.auto-cpufreq --epp --set=balance_performance", shell=True) + print('Setting to use: "balance_performance" EPP') # set frequencies set_frequencies() From b3343b93b076587c45e1a3df507ade2ee1c1a9bd Mon Sep 17 00:00:00 2001 From: PhoenixCausesOof Date: Tue, 23 Jan 2024 19:52:52 -0300 Subject: [PATCH 2/3] Fix indentation --- auto_cpufreq/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index f388865e..e46224b0 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -901,7 +901,7 @@ def set_performance(): ) - if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() is false: + if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() is false: print('Not setting EPP (not supported by system)') else: dynboost_enabled = Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() From e1c53606deaa47f6ddc3b6903eb0fac49ff59770 Mon Sep 17 00:00:00 2001 From: PhoenixCausesOof Date: Tue, 23 Jan 2024 20:32:01 -0300 Subject: [PATCH 3/3] Fix bool literal --- auto_cpufreq/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index e46224b0..e355ff3e 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py @@ -674,7 +674,7 @@ def set_powersave(): run(f"cpufreqctl.auto-cpufreq --governor --set={gov}", shell=True) - if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() is false: + if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() is False: print('Not setting EPP (not supported by system)') else: dynboost_enabled = Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists() @@ -901,7 +901,7 @@ def set_performance(): ) - if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() is false: + if Path("/sys/devices/system/cpu/cpu0/cpufreq/energy_performance_preference").exists() is False: print('Not setting EPP (not supported by system)') else: dynboost_enabled = Path("/sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost").exists()