Skip to content

Commit

Permalink
Populate Vendor field for ARM cpus
Browse files Browse the repository at this point in the history
In ARM  systems, `/proc/cpuinfo` file does not contain `vendor_id` fields. In `lscpu` tool,
the `CPU implementor` code and a lookup table is used to provide a human readable
vendor name [1].

Populate `cpu.Info.Processors[*].Vendor` field with "ARM" string when running in ARM systems.

[1] util-linux/util-linux#564

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
  • Loading branch information
zeeke committed Oct 24, 2024
1 parent e050c5a commit 37a20d2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/cpu/cpu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func processorsGet(ctx *context.Context) []*Processor {
proc.Vendor = lp.Attrs["vendor_id"]
} else if len(lp.Attrs["isa"]) != 0 { // RISCV64
proc.Vendor = lp.Attrs["isa"]
} else if lp.Attrs["CPU implementer"] == "0x41" { // ARM
proc.Vendor = "ARM"
}
procs[procID] = proc
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/cpu/cpu_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ func TestArmCPU(t *testing.T) {
}

for _, p := range info.Processors {
if p.Vendor == "" {
t.Fatalf("Expected not empty vendor field.")
}
if p.TotalCores == 0 {
t.Fatalf("Expected >0 cores but got 0.")
}
Expand Down

0 comments on commit 37a20d2

Please sign in to comment.