This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Don't fall back to mmap if the original arena is not corrupt
- From: "Siddhesh Poyarekar" <siddhesh at redhat dot com>
- To: libc-alpha at sourceware dot org
- Cc: Josef Bacik <josef at toxicpanda dot com>
- Date: Wed, 19 Aug 2015 14:32:21 +0530
- Subject: [PATCH] Don't fall back to mmap if the original arena is not corrupt
- Authentication-results: sourceware.org; auth=none
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