From patchwork Tue Jun 21 15:21:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 13290 Received: (qmail 67110 invoked by alias); 21 Jun 2016 15:21:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 67100 invoked by uid 89); 21 Jun 2016 15:21:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=premature X-HELO: mx1.redhat.com Date: Tue, 21 Jun 2016 17:21:18 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] malloc: Avoid premature fallback to mmap [BZ #20284] User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20160621152118.20F8F402276E4@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2016-06-21 Florian Weimer [BZ #20284] * malloc/arena.c (reused_arena): Do not return NULL if we start out with a non-corrupted arena. diff --git a/malloc/arena.c b/malloc/arena.c index ed5a4d5..229783f 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -771,14 +771,12 @@ reused_arena (mstate avoid_arena) { result = result->next; if (result == begin) - break; + /* We looped around the arena list. We could not find any + arena that was either not corrupted or not the one we + wanted to avoid. */ + return NULL; } - /* 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) - return NULL; - /* No arena available without contention. Wait for the next in line. */ LIBC_PROBE (memory_arena_reuse_wait, 3, &result->mutex, result, avoid_arena); (void) mutex_lock (&result->mutex);