2011-12-22 19:25:40 +00:00
|
|
|
* malloc/arena.c (arena_get2): Avoid unnecessarily
|
|
|
|
retrieving #cpus from /proc.
|
|
|
|
* malloc/malloc.c (mALLOPt): Clamp arena_test based on
|
|
|
|
the value of arena_max.
|
|
|
|
|
2012-02-01 16:32:10 +00:00
|
|
|
commit 41b81892f11fe1353123e892158b53de73863d62
|
|
|
|
Author: Ulrich Drepper <drepper@gmail.com>
|
|
|
|
Date: Tue Jan 31 14:42:34 2012 -0500
|
|
|
|
|
|
|
|
Handle ARENA_TEST correctly
|
|
|
|
|
2011-12-22 19:25:40 +00:00
|
|
|
diff --git a/malloc/arena.c b/malloc/arena.c
|
2012-02-01 16:32:10 +00:00
|
|
|
index d3cf4b9..b1c9469 100644
|
2011-12-22 19:25:40 +00:00
|
|
|
--- a/malloc/arena.c
|
|
|
|
+++ b/malloc/arena.c
|
|
|
|
@@ -828,7 +828,7 @@ arena_get2(mstate a_tsd, size_t size)
|
|
|
|
{
|
|
|
|
if (mp_.arena_max != 0)
|
|
|
|
narenas_limit = mp_.arena_max;
|
|
|
|
- else
|
|
|
|
+ else if (narenas > mp_.arena_test)
|
|
|
|
{
|
|
|
|
int n = __get_nprocs ();
|
|
|
|
|
2012-02-01 16:32:10 +00:00
|
|
|
@@ -842,7 +842,14 @@ arena_get2(mstate a_tsd, size_t size)
|
|
|
|
}
|
|
|
|
repeat:;
|
|
|
|
size_t n = narenas;
|
|
|
|
- if (__builtin_expect (n <= mp_.arena_test || n < narenas_limit, 0))
|
|
|
|
+ /* NB: the following depends on the fact that (size_t)0 - 1 is a
|
|
|
|
+ very large number and that the underflow is OK. If arena_max
|
|
|
|
+ is set the value of arena_test is irrelevant. If arena_test
|
|
|
|
+ is set but narenas is not yet larger or equal to arena_test
|
|
|
|
+ narenas_limit is 0. There is no possibility for narenas to
|
|
|
|
+ be too big for the test to always fail since there is not
|
|
|
|
+ enough address space to create that many arenas. */
|
|
|
|
+ if (__builtin_expect (n <= narenas_limit - 1, 0))
|
|
|
|
{
|
|
|
|
if (catomic_compare_and_exchange_bool_acq (&narenas, n + 1, n))
|
|
|
|
goto repeat;
|