📣 Post by marcan

2024-11-26 ┃ edited

PSA: If you're reading and parsing /proc/cpuinfo for anything, you should probably stop.
The CPU information you're probably looking for is available in structured form in /sys/devices/system/cpu, no horrible text parsing required. And unlike /proc/cpuinfo, the /sys hierarchy is standardized across architectures (as much as is practical). In particular, you will not find CPU topology info in /proc/cpuinfo on non-x86 architectures.
Signed, ARM64 users who keep seeing things like "1 cpu, 1 core, 8 threads" in software written by x86 users (I'm looking at you, GeekBench).

marcan

https://social.treehouse.systems/@marcan/113548772069263164

🔄 dalias

🔄 drwho

💬 Replies

2024-12-02 Conan_Kudo ┃ 1👤

@marcan FYI @serebit

2024-11-27 mmu_man

@marcan and if all you need is to know how many threads to spawn to scale on cores:
sysconf(_SC_NPROCESSORS_CONF); /* processors configured */
sysconf(_SC_NPROCESSORS_ONLN); /* […]

2024-11-27 hrw

@marcan When all you need is quick grep through "cpu features" flags then `/proc/cpuinfo` gives you readable names.
`/sys/devices/system/cpu/modalias` gives you hex codes for which you need to […]

────

📡 Local feed

🏕️ Communities

🔥 Hashtags

🔎 Search posts

🔑 Sign in

📊 Status

🛟 Help