Skip to content

Commit

Permalink
genretlat: Fix model number parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Andi Kleen committed Aug 30, 2024
1 parent b4a7c5e commit a2e6808
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions genretlat.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,21 @@ def human_output(data):
print("%s %s " % (m.lower(), d[ev][m]), end="")
print()

def get_model_number():
with open("/proc/cpuinfo") as f:
for l in f:
n = l.split()
if len(n) >= 3 and n[0] == "model" and n[1] == ":":
return int(n[2])
return 0

def find_model(args):
if not args.cpu:
cpu = open("/sys/devices/cpu/caps/pmu_name").read()
cpu = open("/sys/devices/cpu/caps/pmu_name").read().strip()
if cpu == "meteorlake_hybrid":
args.cpu = "mtl"
elif cpu == "sapphire_rapids":
m = [n for n in open("/proc/cpuinfo") if n.startswith("model ")]
model = int(m[0].split()[2])
model = get_model_number()
if model == 0xad or model == 0xae:
args.cpu = "gnr"
else:
Expand Down

0 comments on commit a2e6808

Please sign in to comment.