From 83256398be7df65ed90ee5ede452d455ce11b5b6 Mon Sep 17 00:00:00 2001 From: sgthammer <36170195+sgthammer@users.noreply.github.com> Date: Tue, 6 Dec 2022 14:56:51 +0300 Subject: [PATCH] fill modelName for all cores in arm64 devices --- cpu/cpu_linux.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index 44bf1ce4f..a60e462d6 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -242,6 +242,17 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.Family = value case "model", "CPU part": c.Model = value + // if CPU is arm based, model name is found via model number. refer to: arch/arm64/kernel/cpuinfo.c + if c.VendorID == "ARM" { + if v, err := strconv.ParseUint(c.Model, 0, 16); err == nil { + modelName, exist := armModelToModelName[v] + if exist { + c.ModelName = modelName + } else { + c.ModelName = "Undefined" + } + } + } case "model name", "cpu": c.ModelName = value if strings.Contains(value, "POWER8") || @@ -285,16 +296,6 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) { c.Microcode = value } } - if c.VendorID == "ARM" && c.ModelName == "" { - if v, err := strconv.ParseUint(c.Model, 0, 16); err == nil { - modelName, exist := armModelToModelName[v] - if exist { - c.ModelName = modelName - } else { - c.ModelName = "Undefined" - } - } - } if c.CPU >= 0 { finishCPUInfo(&c) ret = append(ret, c)