From patchwork Fri Jun 13 15:41:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 31879 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4533C2054B for ; Fri, 13 Jun 2014 15:42:04 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id hy10sf8157936vcb.9 for ; Fri, 13 Jun 2014 08:42:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=cfnnY3prjki2pVdF7N9qiy9bpAiMqPpIxYOZUf7YGsc=; b=OVj3ZnqbpqmkdZFKpAHl9FX3IqlQ9LDXJ7wHkIZ+uuvhgPVRxFYlwJVQYl787kTc0R PLcKWZqFb7OOZ3Y+r+4EoYQAsEv1Vf00235NSCJLm/wgZvrxEtN8gcu8aNrPvFVY8Rng qiyAE3L/mVFC0nHdvinFKN/RTvP79c9GtSZMcZ9HaRXN618O0QEG1acoYYcTigMQS77h k0lUgWLGISoLeyzA+CfX75Pkse+81X7BG0DBXZzhkqcmZ5AG0z3bg+MSQvwh+j8lbH16 Ea6/PKUijvT4nIW4hekw/bzawm9mS2OhhB+GYEVGW7fU0CYtjaAlb32LsZhWMfO6vytt no/w== X-Gm-Message-State: ALoCoQlLsthj929RFtKhMMQdp7ko5lhA2OoKdbLuOhgi+X4W6SYkJkx8Kwa4UxF8Omyg6Z94nrVp X-Received: by 10.236.29.37 with SMTP id h25mr522532yha.8.1402674123950; Fri, 13 Jun 2014 08:42:03 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.130 with SMTP id q2ls3678108qga.91.gmail; Fri, 13 Jun 2014 08:42:03 -0700 (PDT) X-Received: by 10.58.132.41 with SMTP id or9mr2345606veb.5.1402674123796; Fri, 13 Jun 2014 08:42:03 -0700 (PDT) Received: from mail-ve0-x230.google.com (mail-ve0-x230.google.com [2607:f8b0:400c:c01::230]) by mx.google.com with ESMTPS id qe9si1527129vcb.79.2014.06.13.08.42.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Jun 2014 08:42:03 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::230 as permitted sender) client-ip=2607:f8b0:400c:c01::230; Received: by mail-ve0-f176.google.com with SMTP id db12so3478214veb.21 for ; Fri, 13 Jun 2014 08:42:03 -0700 (PDT) X-Received: by 10.58.178.2 with SMTP id cu2mr409830vec.70.1402674123653; Fri, 13 Jun 2014 08:42:03 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp501850vcb; Fri, 13 Jun 2014 08:42:03 -0700 (PDT) X-Received: by 10.66.216.197 with SMTP id os5mr4393396pac.29.1402674122836; Fri, 13 Jun 2014 08:42:02 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ct4si2527801pbb.189.2014.06.13.08.42.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jun 2014 08:42:02 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-50800-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 13747 invoked by alias); 13 Jun 2014 15:41:54 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 13733 invoked by uid 89); 13 Jun 2014 15:41:53 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f181.google.com X-Received: by 10.194.176.1 with SMTP id ce1mr5406387wjc.79.1402674109612; Fri, 13 Jun 2014 08:41:49 -0700 (PDT) From: Will Newton To: libc-alpha@sourceware.org Subject: [PATCH] malloc/malloc.c: Avoid calling sbrk unnecessarily with zero Date: Fri, 13 Jun 2014 16:41:44 +0100 Message-Id: <1402674104-13759-1-git-send-email-will.newton@linaro.org> X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::230 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 Due to my bad review suggestion for the fix for BZ #15089 a check was removed from systrim to prevent sbrk being called with a zero argument. Add the check back to avoid this useless work. ChangeLog: 2014-06-13 Will Newton * malloc/malloc.c (systrim): If extra is zero then return early. --- malloc/malloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/malloc/malloc.c b/malloc/malloc.c index d8fd8b4..41fd76a 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2749,6 +2749,9 @@ systrim (size_t pad, mstate av) /* Release in pagesize units, keeping at least one page */ extra = (top_area - pad) & ~(pagesz - 1); + if (extra == 0) + return 0; + /* Only proceed if end of memory is where we last set it. This avoids problems if there were foreign sbrk calls.