[PATCH] Don't fall back to mmap if the original arena is not corrupt
Siddhesh Poyarekar
siddhesh@redhat.com
Wed Aug 19 09:03:00 GMT 2015
From: Josef Bacik <josef@toxicpanda.com>
The new logic to find an uncontended non-corrupt arena misses a case
where the current arena is contended, but is not corrupt. In the
degenerate case, this is the only arena. In both cases, the logic
falls back to using mmap despite there being an available arena.
Attached patch by Josef Bacik makes sure that all arenas are indeed
corrupt before falling back to malloc. Verified on x86_64.
* malloc/arena.c (reused_arena): return NULL only if all
arenas are corrupt.
---
malloc/arena.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/malloc/arena.c b/malloc/arena.c
index 21ecc5a1..0424273 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -823,16 +823,21 @@ reused_arena (mstate avoid_arena)
/* Make sure that the arena we get is not corrupted. */
mstate begin = result;
+ bool looped = false;
+
while (arena_is_corrupt (result) || result == avoid_arena)
{
result = result->next;
if (result == begin)
- break;
+ {
+ looped = true;
+ break;
+ }
}
/* We could not find any arena that was either not corrupted or not the one
we wanted to avoid. */
- if (result == begin || result == avoid_arena)
+ if (looped)
return NULL;
/* No arena available without contention. Wait for the next in line. */
--
2.4.3
More information about the Libc-alpha
mailing list