Try to use sysctl(3) instead of sysctlbyname(3).
This attempts to use VM_OVERCOMMIT OID - newly introduced in -CURRENT few days ago, specifically for this purpose - instead of querying the sysctl by its string name. Due to how syctlbyname(3) works, this means we do one syscall during binary startup instead of two. Signed-off-by: Edward Tomasz Napierala <trasz@FreeBSD.org>
This commit is contained in:
parent
d591df05c8
commit
9f455e2786
13
src/pages.c
13
src/pages.c
@ -10,6 +10,9 @@
|
|||||||
|
|
||||||
#ifdef JEMALLOC_SYSCTL_VM_OVERCOMMIT
|
#ifdef JEMALLOC_SYSCTL_VM_OVERCOMMIT
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <vm/vm_param.h>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -375,9 +378,19 @@ os_overcommits_sysctl(void) {
|
|||||||
size_t sz;
|
size_t sz;
|
||||||
|
|
||||||
sz = sizeof(vm_overcommit);
|
sz = sizeof(vm_overcommit);
|
||||||
|
#if defined(__FreeBSD__) && defined(VM_OVERCOMMIT)
|
||||||
|
int mib[2];
|
||||||
|
|
||||||
|
mib[0] = CTL_VM;
|
||||||
|
mib[1] = VM_OVERCOMMIT;
|
||||||
|
if (sysctl(mib, 2, &vm_overcommit, &sz, NULL, 0) != 0) {
|
||||||
|
return false; /* Error. */
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (sysctlbyname("vm.overcommit", &vm_overcommit, &sz, NULL, 0) != 0) {
|
if (sysctlbyname("vm.overcommit", &vm_overcommit, &sz, NULL, 0) != 0) {
|
||||||
return false; /* Error. */
|
return false; /* Error. */
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return ((vm_overcommit & 0x3) == 0);
|
return ((vm_overcommit & 0x3) == 0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user