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.

Reported by:	kris
This commit is contained in:
Jason Evans 2008-11-03 21:17:18 +00:00
parent 4482f952b1
commit b74d3e0c37
2 changed files with 18 additions and 13 deletions

View File

@ -255,7 +255,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

View File

@ -1536,11 +1536,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
{
@ -1548,6 +1543,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);
}
@ -1983,6 +1986,15 @@ chunk_alloc(size_t size, bool zero)
assert(size != 0);
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);
@ -1994,14 +2006,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;