Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fill modelName for all cores in arm64 devices #1389

Merged
merged 1 commit into from Dec 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 11 additions & 10 deletions cpu/cpu_linux.go
Expand Up @@ -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") ||
Expand Down Expand Up @@ -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)
Expand Down