saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.1k stars 5.47k forks source link

grain cpu_family #58310

Open steverweber opened 4 years ago

steverweber commented 4 years ago

The architecture family of a cpu would be helpful to have in grains. This would make it more simple when installing packages that are architecture family related.

My previous workaround was looking at the cpu_flags.

On many Linux systems you can cat /sys/devices/cpu/caps/pmu_name I'm not sure about other kernels

waynew commented 4 years ago

@steverweber I'm confused - are you talking about x86_64 vs arm64? Or something else? 🤔

steverweber commented 3 years ago

Something else

more info: https://unix.stackexchange.com/questions/230634/how-to-find-out-intel-architecture-family-from-command-line

CPUs often have 'family' or microarchitecture names. After some testing it seems that the file is not always reliable.

root@jupyter-p03:~# salt-call grains.get cpu_model
local:
    AMD EPYC 7702P 64-Core Processor

root@jupyter-p03:~# cat /sys/devices/cpu/caps/pmu_name
cat: /sys/devices/cpu/caps/pmu_name: No such file or directory
** I assume newer kernels will have this output `zen2`

root@jupyter-p03:~# gcc -march=native -Q --help=target|grep march
  -march=                               znver2
Some Intel CPUs
salt cpu\* cmd.run 'cat /sys/devices/cpu/caps/pmu_name'
cpu145:
    broadwell
cpu150:
    skylake
cpu21:
    sandybridge