jaypipes / ghw

Go HardWare discovery/inspection library
Apache License 2.0
1.62k stars 174 forks source link

Add aarch64 and RISCV64 support #303

Closed rockrush closed 1 year ago

rockrush commented 2 years ago

Depend on sysfs instead of /proc/cpuinfo, for content of this file varies across CPU architectures, and doesn't offer unified info tag.

Solves issue #199 .

Signed-off-by: Xingyou Chen rockrush@rockwork.org

ffromani commented 2 years ago

Thanks for this PR! I'm generally in favour of moving from /proc/cpuinfo to sysfs to learn about the CPU data. Let's check this change is covered by the existing tests, and let's add more of them if needed other than that, at glance looks good! I'll have a deeper look later

ffromani commented 2 years ago

/cc @jaypipes because cpuinfo -> sysfs move and support for extra arches

Itxaka commented 2 years ago

we would need some aarch64 and riscv64 machines to run at least some CI on; unfortunately, code outside CI bitrots pretty fast. I'm not aware of option (not sure gh actions run on arm, IIRC not)

FYI you can run tests on qemu arm64 under github ci. Yes, its slow as hell, and you need to ssh into the VM to run your tests, but seems to work as expected, we run our battery of tests on it, even installing and restarting the vm to test different things and we can say it works.

See a vagrantfile to bring machine X up on qemu-system-aarch64: https://github.com/rancher-sandbox/cOS-toolkit/blob/master/tests/Vagrantfile#L30 and the makefile that brings it up: https://github.com/rancher-sandbox/cOS-toolkit/blob/master/make/Makefile.test#L61

Let me know if you need any help in this area (testing on aarch64 vms on github ci!) :)

ffromani commented 2 years ago

we would need some aarch64 and riscv64 machines to run at least some CI on; unfortunately, code outside CI bitrots pretty fast. I'm not aware of option (not sure gh actions run on arm, IIRC not)

FYI you can run tests on qemu arm64 under github ci. Yes, its slow as hell, and you need to ssh into the VM to run your tests, but seems to work as expected, we run our battery of tests on it, even installing and restarting the vm to test different things and we can say it works.

See a vagrantfile to bring machine X up on qemu-system-aarch64: https://github.com/rancher-sandbox/cOS-toolkit/blob/master/tests/Vagrantfile#L30 and the makefile that brings it up: https://github.com/rancher-sandbox/cOS-toolkit/blob/master/make/Makefile.test#L61

Let me know if you need any help in this area (testing on aarch64 vms on github ci!) :)

that would help a lot indeed, thanks! I'll review your suggestion ASAP (time allowing) and we'll try to move this forward. The bright side is the ghw testsuite runs really fast - let's try to keep it this way!

jak3kaj commented 1 year ago

This PR resolves CPU discovery issues on an ARMv7 network switch as well.

I would like to see this PR merged into main.

ffromani commented 1 year ago

adding arm support would be very nice indeed. Unfortunately we still need to sort out the CI and the supportability aspects, because we very much want to avoid the feature to break (or to break silently!) when the projects moves on.

jak3kaj commented 1 year ago

Understood.

I'm going to work on adding arm support for some of the data that's usually stored in dmi on x86. I will also work on setting up some arm CI in a fork and I'll circle back to see if that will be suitable for this project too.

glimchb commented 1 year ago

FYI @jaypipes merged #333 , this can be closed

Itxaka commented 1 year ago

nice!