Files
Linux-Kernel-Programming_2E/ch11
Mohammad Rahimi 784b8be891 Fix incorrect CPU core count when displaying affinity mask
The current implementation uses `nproc` to query the number
of available CPUs. However, when restricting the cores that
`userspc_cpuaffinity` can run on (e.g., via `taskset -c`),
the affinity mask table is incorrectly displayed. For example,
running `taskset -c 2 ./userspc_cpuaffinity` results in a
single-column table displaying a wrong core id.

This commit resolves the issue by replacing `nproc` with
`get_nprocs()` from `sys/sysinfo.h`, which provides the correct
number of processors after core restrictions are applied.
2025-01-01 04:52:52 +00:00
..