From 3a3152a36f6f7ce6bafae3538924fac481434e26 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 10 Aug 2026 11:33:03 +0200 Subject: [PATCH] Comment about syshex --- cmdline/unixapp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmdline/unixapp.c b/cmdline/unixapp.c index 6fc5ef09..54a4da1a 100644 --- a/cmdline/unixapp.c +++ b/cmdline/unixapp.c @@ -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 */