config_cpu: use lscpu for identifying CPU information
authorMichael Prokop <mika@grml.org>
Fri, 8 Sep 2023 06:32:21 +0000 (08:32 +0200)
committerMichael Prokop <mika@grml.org>
Fri, 8 Sep 2023 06:35:25 +0000 (08:35 +0200)
commit74eef776a281bca6f6d6f089b065cb01dc600196
treec5ca715604cb06a99d52e2db4e75db75efff0878
parentbd414ee95f95b6c77d636aba947db0a16ab87618
config_cpu: use lscpu for identifying CPU information

On arm64 we don't have the CPU information in /proc/cpuinfo as expected
by our config_cpu, so its output is broken:

| # awk -F: '/^processor/{printf "        Processor"$2" is"};/^model name/{printf $2};/^vendor_id/{printf vendor};/^cpu MHz/{printf " %dMHz",int($2)};/^cache size/{printf ","$2" Cache"};/^$/{print ""}' /proc/cpuinfo
|         Processor 0 is
|         Processor 1 is
| [...]
|         Processor 13 is
|         Processor 14 is
|         Processor 15 is

FTR:

| # head /proc/cpuinfo
| processor       : 0
| BogoMIPS        : 50.00
| Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp ssbs
| CPU implementer : 0x41
| CPU architecture: 8
| CPU variant     : 0x3
| CPU part        : 0xd0c
| CPU revision    : 1
|
| processor       : 1

While with lspcu we get the information we're interested in:

| # lscpu | grep 'Model name:'
| Model name:                      Neoverse-N1
| BIOS Model name:                 virt-5.2  CPU @ 2.0GHz

So instead of having some hackish /proc/cpuinfo parsing, let's rely on
util-linux's lscpu(1).

While at it, let's output only the number of present CPUs instead of
listing every single one of them, given that there exist systems with
>100 CPUs nowadays. :)

Thanks: Christopher Bock and AndrĂ¡s Korn for feedback
autoconfig.functions