opnsense-src/lib/libc/tests/sys
Kyle Evans e760f45b59 libc: report _SC_NPROCESSORS_ONLN more accurately in cpu-limited jails
We don't support CPU hotplug, but we do support cpuset(8) restrictions
on jails (including prison0, which uses cpuset 1).  The process cannot
widen its cpuset beyond its root set, so it makes sense to instead
report the number of cpus enabled there rather than the total number
in the system.

This change is effectively a nop for the majority of systems and jails
in the wild, though it does reduce the performance of this query now
that we can't take advantage of AT_NCPUS being provided in the auxinfo.

The implementation here is notably different than Linux, which would not
take cgroups into account.  They do, however, take CPU hotplug into
account, so the possibility for it to diverge from (and be lower than)
the # configured count to reflect what the process can actually be
scheduled on doesn't really diverge in semantics.

Reviewed by:	kib

(cherry picked from commit d617806aac1469319970e3551656e9deabb98a35)
2026-01-19 22:04:28 -06:00
..
brk_test.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
cpuset_test.c libc: report _SC_NPROCESSORS_ONLN more accurately in cpu-limited jails 2026-01-19 22:04:28 -06:00
errno_test.c libc/sys: add errno test 2024-02-25 22:35:17 +02:00
Makefile libc/powerpc64: Fix swapcontext(3) 2025-07-13 14:00:56 -04:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
mlock_helper.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
queue_test.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
sendfile_test.c libc: Purge unneeded cdefs.h 2023-11-01 16:44:30 -06:00
swapcontext_test.c libc/powerpc64: Fix swapcontext(3) 2025-07-13 14:00:56 -04:00