Comment about syshex

This commit is contained in:
Andrea Mazzoleni 2026-08-10 11:33:03 +02:00
parent 2b71f5727e
commit 3a3152a36f

View file

@ -478,6 +478,17 @@ static long long syslong(const char* path)
return v;
}
/*
* Parse a sysfs hexadecimal bitmask string (e.g. thread_siblings).
*
* Linux sysfs outputs bitmasks in big-endian 32-bit hex word groups
* (highest CPUs on the left, lowest CPUs on the right).
*
* Left-shifting digits into a 64-bit unsigned long long operates modulo 2^64,
* discarding any high-order hex words (CPUs >= 64) and leaving bits 0..63
* containing the exact mask for CPUs 0..63. Since CPUS_MAX is 64, this mask
* is always accurate for all evaluated CPUs even on systems with > 64 CPUs.
*/
static unsigned long long syshex(const char* path)
{
char buf[1152]; /* enough for 1024 CPUs */