[system] Some versions of cpuinfo may return cache sizes in human-readable format.

This commit is contained in:
Fabio Manganiello 2023-11-10 21:55:41 +01:00
parent 9a090d1b46
commit 20aeb0b72e
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -16,6 +16,19 @@ class CpuInfoBaseSchema(SystemBaseSchema):
if data.get('hz_actual'): if data.get('hz_actual'):
data['frequency_actual'] = data.pop('hz_actual')[0] data['frequency_actual'] = data.pop('hz_actual')[0]
for key, value in data.items():
if key.endswith("_cache_size") and isinstance(value, str):
value, unit = value.split(" ")
value = int(value)
if unit == "KiB":
value *= 1024
elif unit == "MiB":
value *= 1024 * 1024
elif unit == "GiB":
value *= 1024 * 1024 * 1024
data[key] = value
return data return data