Make libthr(3) use sysconf(_SC_NPROCESSORS_CONF); this shaves off

two calls to sysctl(2) from the binary startup.

Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D18046
This commit is contained in:
Edward Tomasz Napierala 2018-11-19 18:24:08 +00:00
parent 3a9cdc5132
commit a4f02d5d6d

View File

@ -474,8 +474,9 @@ init_private(void)
PANIC("Cannot get stack rlimit");
_thr_stack_initial = rlim.rlim_cur;
}
len = sizeof(_thr_is_smp);
sysctlbyname("kern.smp.cpus", &_thr_is_smp, &len, NULL, 0);
_thr_is_smp = sysconf(_SC_NPROCESSORS_CONF);
if (_thr_is_smp == -1)
PANIC("Cannot get _SC_NPROCESSORS_CONF");
_thr_is_smp = (_thr_is_smp > 1);
_thr_page_size = getpagesize();
_thr_guard_default = _thr_page_size;