diff options
-rw-r--r-- | lib/libc/stdlib/malloc.c | 17 | ||||
-rw-r--r-- | share/man/man5/malloc.conf.5 | 16 |
2 files changed, 17 insertions, 16 deletions
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index 70e7f37dc82..af9cf39199d 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.250 2018/11/05 08:23:40 otto Exp $ */ +/* $OpenBSD: malloc.c,v 1.251 2018/11/06 08:01:43 otto Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net> * Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org> @@ -28,6 +28,8 @@ #include <sys/types.h> #include <sys/queue.h> #include <sys/mman.h> +#include <sys/sysctl.h> +#include <uvm/uvmexp.h> #include <errno.h> #include <stdarg.h> #include <stdint.h> @@ -386,8 +388,9 @@ omalloc_parseopt(char opt) static void omalloc_init(void) { - char *p, *q, b[64]; - int i, j; + char *p, *q, b[16]; + int i, j, mib[2]; + size_t sb; /* * Default options @@ -398,10 +401,12 @@ omalloc_init(void) for (i = 0; i < 3; i++) { switch (i) { case 0: - j = readlink("/etc/malloc.conf", b, sizeof b - 1); - if (j <= 0) + mib[0] = CTL_VM; + mib[1] = VM_MALLOC_CONF; + sb = sizeof(b); + j = sysctl(mib, 2, b, &sb, NULL, 0); + if (j != 0) continue; - b[j] = '\0'; p = b; break; case 1: diff --git a/share/man/man5/malloc.conf.5 b/share/man/man5/malloc.conf.5 index 556e9934973..6fec0793acd 100644 --- a/share/man/man5/malloc.conf.5 +++ b/share/man/man5/malloc.conf.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: malloc.conf.5,v 1.14 2018/03/19 13:35:06 otto Exp $ +.\" $OpenBSD: malloc.conf.5,v 1.15 2018/11/06 08:01:43 otto Exp $ .\" .\" Copyright (c) 2012 Damien Miller <djm@openbsd.org> .\" Copyright (c) 2008, 2009, 2010, 2011 Otto Moerbeek <otto@drijf.net> @@ -17,7 +17,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 19 2018 $ +.Dd $Mdocdate: November 6 2018 $ .Dt MALLOC.CONF 5 .Os .Sh NAME @@ -27,8 +27,9 @@ Upon the first call to the .Xr malloc 3 family of functions, an initialization sequence inspects the -symbolic link -.Pa /etc/malloc.conf , +value of the +.Va vm.malloc_conf +.Xr sysctl 3 , next checks the environment for a variable called .Ev MALLOC_OPTIONS , and finally looks at the global variable @@ -137,15 +138,10 @@ Multi-threaded programs use multiple pools. .It Ev MALLOC_OPTIONS string of option flags .El -.Sh FILES -.Bl -tag -width "/etc/malloc.conf" -.It Pa /etc/malloc.conf -symbolic link to filename containing option flags -.El .Sh EXAMPLES Set a systemwide reduction of the cache to a quarter of the default size and use guard pages: .Pp -.Dl # ln -s 'G<<' /etc/malloc.conf +.Dl # sysctl vm.malloc_conf='G<<' .Sh SEE ALSO .Xr malloc 3 |