mirror of
https://github.com/erpalma/throttled.git
synced 2026-02-02 05:44:14 +01:00
This commit is contained in:
parent
99148e27f0
commit
1fd44fdc30
|
|
@ -196,6 +196,21 @@ def get_value_for_bits(val, from_bit=0, to_bit=63):
|
|||
return (val & mask) >> from_bit
|
||||
|
||||
|
||||
def set_msr_allow_writes():
|
||||
log('[I] Trying to unlock MSR allow_writes.')
|
||||
if not os.path.exists('/sys/module/msr'):
|
||||
try:
|
||||
subprocess.check_call(('modprobe', 'msr'))
|
||||
except subprocess.CalledProcessError:
|
||||
return
|
||||
if os.path.exists('/sys/module/msr/parameters/allow_writes'):
|
||||
try:
|
||||
with open('/sys/module/msr/parameters/allow_writes', 'w') as f:
|
||||
f.write('on')
|
||||
except:
|
||||
warning('Unable to set MSR allow_writes to on. You might experience warnings in kernel logs.')
|
||||
|
||||
|
||||
def is_on_battery(config):
|
||||
try:
|
||||
for path in glob.glob(config.get('GENERAL', 'Sysfs_Power_Path', fallback=DEFAULT_SYSFS_POWER_PATH)):
|
||||
|
|
@ -813,6 +828,8 @@ def main():
|
|||
check_kernel()
|
||||
check_cpu()
|
||||
|
||||
set_msr_allow_writes()
|
||||
|
||||
log('[I] Loading config file.')
|
||||
config = load_config()
|
||||
power['source'] = 'BATTERY' if is_on_battery(config) else 'AC'
|
||||
|
|
|
|||
Loading…
Reference in a new issue