svn commit: r184819 - in stable/7/lib/libc: . stdlib

Jason Evans jasone at FreeBSD.org
Mon Nov 10 09:30:49 PST 2008


Author: jasone
Date: Mon Nov 10 17:30:49 2008
New Revision: 184819
URL: http://svn.freebsd.org/changeset/base/184819

Log:
  MFC:
  	Revert to preferring mmap(2) over sbrk(2) when mapping memory, due
  	to potential extreme contention in the kernel for multi-threaded
  	applications on SMP systems.
  
  Approved by:	re (kib)

Modified:
  stable/7/lib/libc/   (props changed)
  stable/7/lib/libc/stdlib/malloc.3
  stable/7/lib/libc/stdlib/malloc.c

Modified: stable/7/lib/libc/stdlib/malloc.3
==============================================================================
--- stable/7/lib/libc/stdlib/malloc.3	Mon Nov 10 16:44:25 2008	(r184818)
+++ stable/7/lib/libc/stdlib/malloc.3	Mon Nov 10 17:30:49 2008	(r184819)
@@ -250,7 +250,7 @@ If both the
 .Dq D
 and
 .Dq M
-options are enabled, the allocator prefers the DSS over anonymous mappings,
+options are enabled, the allocator prefers anonymous mappings over the DSS,
 but allocation only fails if memory cannot be acquired via either method.
 If neither option is enabled, then the
 .Dq M

Modified: stable/7/lib/libc/stdlib/malloc.c
==============================================================================
--- stable/7/lib/libc/stdlib/malloc.c	Mon Nov 10 16:44:25 2008	(r184818)
+++ stable/7/lib/libc/stdlib/malloc.c	Mon Nov 10 17:30:49 2008	(r184819)
@@ -1275,11 +1275,6 @@ base_pages_alloc(size_t minsize)
 {
 
 #ifdef MALLOC_DSS
-	if (opt_dss) {
-		if (base_pages_alloc_dss(minsize) == false)
-			return (false);
-	}
-
 	if (opt_mmap && minsize != 0)
 #endif
 	{
@@ -1287,6 +1282,14 @@ base_pages_alloc(size_t minsize)
 			return (false);
 	}
 
+#ifdef MALLOC_DSS
+	if (opt_dss) {
+		if (base_pages_alloc_dss(minsize) == false)
+			return (false);
+	}
+
+#endif
+
 	return (true);
 }
 
@@ -1709,6 +1712,15 @@ chunk_alloc(size_t size, bool zero)
 	assert((size & chunksize_mask) == 0);
 
 #ifdef MALLOC_DSS
+	if (opt_mmap)
+#endif
+	{
+		ret = chunk_alloc_mmap(size);
+		if (ret != NULL)
+			goto RETURN;
+	}
+
+#ifdef MALLOC_DSS
 	if (opt_dss) {
 		ret = chunk_recycle_dss(size, zero);
 		if (ret != NULL) {
@@ -1719,14 +1731,7 @@ chunk_alloc(size_t size, bool zero)
 		if (ret != NULL)
 			goto RETURN;
 	}
-
-	if (opt_mmap)
 #endif
-	{
-		ret = chunk_alloc_mmap(size);
-		if (ret != NULL)
-			goto RETURN;
-	}
 
 	/* All strategies for allocation failed. */
 	ret = NULL;


More information about the svn-src-stable-7 mailing list