Merge pull request #372 from sandy-8925/disabled_cpu_fix

Only attempt changing currently enabled CPUs
This commit is contained in:
Francesco Palmarini 2026-01-19 21:54:03 +01:00 committed by GitHub
commit 26021c8cd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -222,8 +222,11 @@ def warning(msg, oneshot=True, end='\n'):
log_history.add(msg.strip())
def get_msr_list():
return ['/dev/cpu/{:d}/msr'.format(int(x)) for x in os.listdir("/dev/cpu")]
def writemsr(msr, val):
msr_list = ['/dev/cpu/{:d}/msr'.format(x) for x in range(cpu_count())]
msr_list = get_msr_list()
if not os.path.exists(msr_list[0]):
try:
subprocess.check_call(('modprobe', 'msr'))
@ -254,7 +257,7 @@ def readmsr(msr, from_bit=0, to_bit=63, cpu=None, flatten=False):
assert cpu is None or cpu in range(cpu_count())
if from_bit > to_bit:
fatal('Wrong readmsr bit params')
msr_list = ['/dev/cpu/{:d}/msr'.format(x) for x in range(cpu_count())]
msr_list = get_msr_list()
if not os.path.exists(msr_list[0]):
try:
subprocess.check_call(('modprobe', 'msr'))