git: 0ae364adcd8d - main - jemalloc: use auxv ELF_BSDF_VMNOOVERCOMMIT instead of sysctl("vm.overcommit")

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 16 Sep 2022 20:25:41 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=0ae364adcd8d34bda3fe1a32e86025ba96df058a

commit 0ae364adcd8d34bda3fe1a32e86025ba96df058a
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-09-12 19:44:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-09-16 20:23:52 +0000

    jemalloc: use auxv ELF_BSDF_VMNOOVERCOMMIT instead of sysctl("vm.overcommit")
    
    Reviewed by:    brooks, imp (previous version)
    Discussed with: markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      2 weeks
    Differential revision:  https://reviews.freebsd.org/D36540
---
 contrib/jemalloc/src/pages.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/contrib/jemalloc/src/pages.c b/contrib/jemalloc/src/pages.c
index 3600443e2cb5..6b00eb0cb919 100644
--- a/contrib/jemalloc/src/pages.c
+++ b/contrib/jemalloc/src/pages.c
@@ -11,6 +11,7 @@
 #ifdef JEMALLOC_SYSCTL_VM_OVERCOMMIT
 #include <sys/sysctl.h>
 #ifdef __FreeBSD__
+#include <sys/auxv.h>
 #include <vm/vm_param.h>
 #include <vm/vm.h>
 #endif
@@ -441,6 +442,13 @@ os_overcommits_sysctl(void) {
 	int vm_overcommit;
 	size_t sz;
 
+#ifdef ELF_BSDF_VMNOOVERCOMMIT
+	int bsdflags;
+
+	if (_elf_aux_info(AT_BSDFLAGS, &bsdflags, sizeof(bsdflags)) == 0)
+		return ((bsdflags & ELF_BSDF_VMNOOVERCOMMIT) == 0);
+#endif
+
 	sz = sizeof(vm_overcommit);
 #if defined(__FreeBSD__) && defined(VM_OVERCOMMIT)
 	int mib[2];