git: 19a2e5ad5998 - stable/13 - jemalloc: use auxv ELF_BSDF_VMNOOVERCOMMIT instead of sysctl("vm.overcommit")

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 30 Sep 2022 02:04:14 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=19a2e5ad599895c422eaf458484044b904b99bbd

commit 19a2e5ad599895c422eaf458484044b904b99bbd
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-09-12 19:44:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-09-30 00:29:10 +0000

    jemalloc: use auxv ELF_BSDF_VMNOOVERCOMMIT instead of sysctl("vm.overcommit")
    
    (cherry picked from commit 0ae364adcd8d34bda3fe1a32e86025ba96df058a)
---
 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];