Closed 44ron closed 10 months ago
hello and thank you for reaching out :) , could you please share the output of your lscpu command so we can think on how to write a general solution?
on my Pi4 with Pi OS full (debian 11) it works as lscpu | awk '/^Socket\(s\)/{ print $2 }'
gives me a plain 1 as output. and mine lscpu output is like:
lscpu
Architecture: aarch64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 1
Core(s) per socket: 4
Socket(s): 1
Vendor ID: ARM
So could you also share the output of these comamnds too?:
lscpu | awk '/^Socket\(s\)/{ print $2 }'
lscpu | awk '/^Core\(s\) per socket/{ print $4 }'
lscpu | awk '/^Thread\(s\) per core/{ print $4 }'
Sure. lscpu gives:
$ lscpu Architecture: aarch64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Vendor ID: ARM Model name: Cortex-A72 Model: 3 Thread(s) per core: 1 Core(s) per cluster: 4 Socket(s): - Cluster(s): 1 Stepping: r0p3 CPU(s) scaling MHz: 100% CPU max MHz: 1500.0000 CPU min MHz: 400.0000 BogoMIPS: 108.00 Flags: fp asimd evtstrm crc32 cpuid Caches (sum of all): L1d: 128 KiB (4 instances) L1i: 192 KiB (4 instances) L2: 1 MiB (1 instance) Vulnerabilities: Gather data sampling: Not affected Itlb multihit: Not affected L1tf: Not affected Mds: Not affected Meltdown: Not affected Mmio stale data: Not affected Retbleed: Not affected Spec rstack overflow: Not affected Spec store bypass: Vulnerable Spectre v1: Mitigation; __user pointer sanitization Spectre v2: Vulnerable Srbds: Not affected Tsx async abort: Not affected
lscpu | awk '/^Socket(s)/{ print $2 }' gives:
-
lscpu | awk '/^Core(s) per socket/{ print $4 }' produces nothing.
lscpu | awk '/^Thread(s) per core/{ print $4 }' gives:
1
Since then I simply set the CPU_SOCKETS variable as 1 and CPU_CORES as 4 and it seems to work flawlessly.
Same issue here with RPi Zero 2 W (aarch64) giving - on Socket(s)
Extra info
~/money4band-main# lscpu
Architecture: aarch64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Vendor ID: ARM
Model name: Cortex-A53
Model: 4
Thread(s) per core: 1
Core(s) per cluster: 4
Socket(s): -
Cluster(s): 1
Stepping: r0p4
CPU(s) scaling MHz: 78%
CPU max MHz: 1000.0000
CPU min MHz: 600.0000
BogoMIPS: 38.40
Flags: fp asimd evtstrm crc32 cpuid
Caches (sum of all):
L1d: 128 KiB (4 instances)
L1i: 128 KiB (4 instances)
L2: 512 KiB (1 instance)
it seems that lscpu output is not consistent among all the OS.
Could you please try these two commands on your machine and post the outputs ?
grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}'
and also try :
lscpu -b -p=Core,Socket | grep -v '^#' | sort -u | wc -l
i do not want to use an utility like nproc or similar as some OS could not have it installed
another workaround could be an hardcoded check like: if ! [[ "$CPU_SOCKETS" =~ ^[0-9]+$ ]]; then CPU_SOCKETS=1 # Default to 1 if CPU_SOCKETS is not a number fi
i'll wait for your response and then we can decide which option is the best and most ubiquitous 👍
lscpu -b -p=Core,Socket | grep -v '^#' | sort -u | wc -l
This command prints 4, the first prints nothing
please try the new release and report back if the issue is resolved :)
we moved to lscpu -b -p=Core,Socket | grep -v '^#' | sort -u | wc -l
please try the new release and report back if the issue is resolved :) we moved to
lscpu -b -p=Core,Socket | grep -v '^#' | sort -u | wc -l
Yep, works perfectly, ty :)
Describe the bug runme.sh throws an error for line 246 The output of lscpu has "-" for Sockets on my device and this makes the script unable to use the output.
[...]
Device (please complete the following information):