summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2009-09-26 23:25:22 +0000
committerdes <des@FreeBSD.org>2009-09-26 23:25:22 +0000
commitca7f5e11bd77d20275db4266c3010470050c8a09 (patch)
tree651271fc4ef4755d0023a49c0657fa23feaaf787 /lib/libc
parenta45436ee4714833a11bf829d86620ac727a0d501 (diff)
parent6079decb9019311024359a5172992bb972921e9d (diff)
downloadFreeBSD-src-ca7f5e11bd77d20275db4266c3010470050c8a09.zip
FreeBSD-src-ca7f5e11bd77d20275db4266c3010470050c8a09.tar.gz
Sync from head.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/stdlib/malloc.36
-rw-r--r--lib/libc/stdlib/malloc.c15
2 files changed, 19 insertions, 2 deletions
diff --git a/lib/libc/stdlib/malloc.3 b/lib/libc/stdlib/malloc.3
index a621a24..308ba7b 100644
--- a/lib/libc/stdlib/malloc.3
+++ b/lib/libc/stdlib/malloc.3
@@ -32,7 +32,7 @@
.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd August 26, 2008
+.Dd September 26, 2009
.Dt MALLOC 3
.Os
.Sh NAME
@@ -245,7 +245,8 @@ will be initialized to 0x5a.
This is intended for debugging and will impact performance negatively.
.It K
Double/halve the virtual memory chunk size.
-The default chunk size is 1 MB.
+The default chunk size is the maximum of 1 MB and the largest
+page size that is less than or equal to 4 MB.
.It M
Use
.Xr mmap 2
@@ -561,6 +562,7 @@ _malloc_options = "X";
.Xr alloca 3 ,
.Xr atexit 3 ,
.Xr getpagesize 3 ,
+.Xr getpagesizes 3 ,
.Xr memory 3 ,
.Xr posix_memalign 3
.Sh STANDARDS
diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c
index b56b003..bdc26b6 100644
--- a/lib/libc/stdlib/malloc.c
+++ b/lib/libc/stdlib/malloc.c
@@ -4795,6 +4795,21 @@ malloc_init_hard(void)
}
}
+ /*
+ * Increase the chunk size to the largest page size that is greater
+ * than the default chunk size and less than or equal to 4MB.
+ */
+ {
+ size_t pagesizes[MAXPAGESIZES];
+ int k, nsizes;
+
+ nsizes = getpagesizes(pagesizes, MAXPAGESIZES);
+ for (k = 0; k < nsizes; k++)
+ if (pagesizes[k] <= (1LU << 22))
+ while ((1LU << opt_chunk_2pow) < pagesizes[k])
+ opt_chunk_2pow++;
+ }
+
for (i = 0; i < 3; i++) {
unsigned j;
OpenPOWER on IntegriCloud