Message ID | 1439974941-6577-1-git-send-email-siddhesh@redhat.com |
---|---|
State | New |
Headers | show |
On 19 Aug 2015 14:32, Siddhesh Poyarekar wrote: > 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. verified how ? > --- 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; doesn't this comment explicitly say you don't want to use the avoid arena ? doesn't it need updating now with this change in logic ? -mike
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. */
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(-)