mirror of
https://github.com/erpalma/throttled.git
synced 2026-01-19 23:20:19 +01:00
Merge pull request #210 from hbriese/reload_when_modified
Reload when modified
This commit is contained in:
commit
f02cc40f3c
10
README.md
10
README.md
|
|
@ -291,11 +291,19 @@ This is an example output:
|
|||
[D] core 0 thermal status: reading valid = 1
|
||||
.....
|
||||
```
|
||||
|
||||
## Autoreload
|
||||
Auto reload config on changes (unless it's deleted) can be enabled/disabled in the config
|
||||
|
||||
```
|
||||
[General]
|
||||
Autoreload = True
|
||||
```
|
||||
|
||||
## A word about manufacturer provided tooling
|
||||
Tools provided by your notebook manufacturer like [Dell Power Manager](https://www.dell.com/support/contents/us/en/04/article/product-support/self-support-knowledgebase/software-and-downloads/dell-power-manager) tend to persist their settings to the system board. If you ever had it running under Windows and activated a cool/quiet/silent/saving profile, this setting will still be active when running linux, throttling your system.
|
||||
|
||||
> On my Dell Latitude 5591, not even a BIOS reset to manufacturar default killed the active `Quiet` profile
|
||||
|
||||
|
||||
## Disclaimer
|
||||
This script overrides the default values set by Lenovo. I'm using it without any problem, but it is still experimental so use it at your own risk.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
Enabled: True
|
||||
# SYSFS path for checking if the system is running on AC power
|
||||
Sysfs_Power_Path: /sys/class/power_supply/AC*/online
|
||||
# Auto reload config on changes
|
||||
Autoreload: True
|
||||
|
||||
## Settings to apply while connected to Battery power
|
||||
[BATTERY]
|
||||
|
|
|
|||
|
|
@ -543,6 +543,23 @@ def set_disable_bdprochot():
|
|||
log('[D] BDPROCHOT - write "{:#02x}" - read "{:#02x}" - match {}'.format(0, read_value, match))
|
||||
|
||||
|
||||
def get_config_write_time():
|
||||
try:
|
||||
return os.stat(args.config).st_mtime
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
|
||||
|
||||
def reload_config():
|
||||
config = load_config()
|
||||
regs = calc_reg_values(get_cpu_platform_info(), config)
|
||||
undervolt(config)
|
||||
set_icc_max(config)
|
||||
set_hwp(config.getboolean('AC', 'HWP_Mode', fallback=False))
|
||||
log('[I] Reloading changes.')
|
||||
return config, regs
|
||||
|
||||
|
||||
def power_thread(config, regs, exit_event):
|
||||
try:
|
||||
mchbar_mmio = MMIO(0xFED159A0, 8)
|
||||
|
|
@ -552,6 +569,8 @@ def power_thread(config, regs, exit_event):
|
|||
mchbar_mmio = None
|
||||
|
||||
next_hwp_write = 0
|
||||
last_config_write_time = get_config_write_time() \
|
||||
if config.getboolean('GENERAL', 'Autoreload', fallback=False) else None
|
||||
while not exit_event.is_set():
|
||||
# log thermal status
|
||||
if args.debug:
|
||||
|
|
@ -560,6 +579,13 @@ def power_thread(config, regs, exit_event):
|
|||
for key, value in core_thermal_status.items():
|
||||
log('[D] core {} thermal status: {} = {}'.format(index, key.replace("_", " "), value))
|
||||
|
||||
# Reload config on changes (unless it's deleted)
|
||||
if config.getboolean('GENERAL', 'Autoreload', fallback=False):
|
||||
config_write_time = get_config_write_time()
|
||||
if config_write_time and last_config_write_time != config_write_time:
|
||||
last_config_write_time = config_write_time
|
||||
config, regs = reload_config()
|
||||
|
||||
# switch back to sysfs polling
|
||||
if power['method'] == 'polling':
|
||||
power['source'] = 'BATTERY' if is_on_battery(config) else 'AC'
|
||||
|
|
|
|||
Loading…
Reference in a new issue