From patchwork Fri Jan 10 02:34:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael-Doyle Hudson X-Patchwork-Id: 23069 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 535BC20555 for ; Fri, 10 Jan 2014 02:34:45 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id l109sf2602773yhq.9 for ; Thu, 09 Jan 2014 18:34:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:from:to:subject:in-reply-to:references:user-agent:date :message-id:mime-version:x-original-sender :x-original-authentication-results:content-type; bh=HuhbBmEiQcTBnKRvEMeKTzRt+CuDYOO3GUXVgBOf/WM=; b=QRMYbkjRUKf9GpO9AqbAMIKCdM9SK7btVJFWVdBMavq5jun70bogzwhZ+ztpYbt288 SymSuGP8oup2vDZOJun+AeGB7TYeyDi0TEUnCQGqw9bMsKZt6UgsQTNWUUjpWgSNDMMy XSDP4JrIjjT0SLC2lpcStSageK4xd4MfEf8yJ3vKRH8bP/PQ39/XMJmMORSI7MD6vWOn XlwMOMgMUZd8FPawDSvCxKFcQ9PkqPcYYMtsQmTMSEZ4c6QJ8YqsGqlVTu0183Op5gdQ 10q3ajnS2EeKoccd8Hyj2vOLvJTkCRk/mNcCY1uhdgf4voxNYNV3cT0WExs9+b0Rybvc knrw== X-Gm-Message-State: ALoCoQkBxGdqZuoZdYrDltNQDS58FDBp5MJw/GsBu1WfXI0r75eAyDc+Dn1i2Gytp+HPWdna6m6X X-Received: by 10.236.34.169 with SMTP id s29mr2110215yha.30.1389321284313; Thu, 09 Jan 2014 18:34:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.106 with SMTP id 10ls1282548qed.55.gmail; Thu, 09 Jan 2014 18:34:44 -0800 (PST) X-Received: by 10.49.36.161 with SMTP id r1mr2108705qej.4.1389321284211; Thu, 09 Jan 2014 18:34:44 -0800 (PST) Received: from mail-ve0-x22e.google.com (mail-ve0-x22e.google.com [2607:f8b0:400c:c01::22e]) by mx.google.com with ESMTPS id 10si6781949qag.45.2014.01.09.18.34.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 18:34:44 -0800 (PST) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22e; Received: by mail-ve0-f174.google.com with SMTP id cz12so43699veb.19 for ; Thu, 09 Jan 2014 18:34:44 -0800 (PST) X-Received: by 10.58.253.163 with SMTP id ab3mr74339ved.70.1389321283946; Thu, 09 Jan 2014 18:34:43 -0800 (PST) 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.59.13.131 with SMTP id ey3csp54406ved; Thu, 9 Jan 2014 18:34:43 -0800 (PST) X-Received: by 10.68.8.136 with SMTP id r8mr7822472pba.36.1389321282407; Thu, 09 Jan 2014 18:34:42 -0800 (PST) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e8si5575246pac.111.2014.01.09.18.34.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jan 2014 18:34:42 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-359328-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 10996 invoked by alias); 10 Jan 2014 02:34:24 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10931 invoked by uid 89); 10 Jan 2014 02:34:16 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.7 required=5.0 tests=AWL, BAYES_50, RP_MATCHES_RCVD, SEM_URI, SEM_URIRED autolearn=no version=3.3.2 X-HELO: youngberry.canonical.com Received: from youngberry.canonical.com (HELO youngberry.canonical.com) (91.189.89.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 Jan 2014 02:34:13 +0000 Received: from [120.136.5.22] (helo=narsil) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1W1RvG-0003AM-AK; Fri, 10 Jan 2014 02:34:11 +0000 Received: by narsil (Postfix, from userid 1000) id 66622525AD7; Fri, 10 Jan 2014 15:34:06 +1300 (NZDT) From: Michael Hudson-Doyle To: Ian Lance Taylor , gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Re: [gofrontend-dev] libgo patch committed: Fix 32-bit memory allocation In-Reply-To: References: User-Agent: Notmuch/0.17~rc1+4~g7f07bfd (http://notmuchmail.org) Emacs/24.3.50.2 (x86_64-pc-linux-gnu) Date: Fri, 10 Jan 2014 15:34:06 +1300 Message-ID: <87y52omuox.fsf@canonical.com> MIME-Version: 1.0 X-Original-Sender: michael.hudson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22e is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Ian Lance Taylor writes: > This patch to libgo fixes memory allocation on 32-bit systems when a lot > of memory has been allocated. The problem is described in this patch to > the master repository: https://codereview.appspot.com/49460043 . Here's a patch for the 4.8 branch if you are interested. I haven't tested it yet -- well, it's in progress but I'm not going to hang around long enough for it to finish today. Cheers, mwh diff --git a/libgo/runtime/malloc.goc b/libgo/runtime/malloc.goc index 8ccaa6b..f0871dd 100644 --- a/libgo/runtime/malloc.goc +++ b/libgo/runtime/malloc.goc @@ -541,8 +541,7 @@ runtime_settype_flush(M *mp, bool sysalloc) // (Manually inlined copy of runtime_MHeap_Lookup) p = (uintptr)v>>PageShift; - if(sizeof(void*) == 8) - p -= (uintptr)runtime_mheap->arena_start >> PageShift; + p -= (uintptr)runtime_mheap->arena_start >> PageShift; s = runtime_mheap->map[p]; if(s->sizeclass == 0) { diff --git a/libgo/runtime/mgc0.c b/libgo/runtime/mgc0.c index c3b3211..9f17bdc 100644 --- a/libgo/runtime/mgc0.c +++ b/libgo/runtime/mgc0.c @@ -239,8 +239,7 @@ markonly(void *obj) // (Manually inlined copy of MHeap_LookupMaybe.) k = (uintptr)obj>>PageShift; x = k; - if(sizeof(void*) == 8) - x -= (uintptr)runtime_mheap->arena_start>>PageShift; + x -= (uintptr)runtime_mheap->arena_start>>PageShift; s = runtime_mheap->map[x]; if(s == nil || k < s->start || k - s->start >= s->npages || s->state != MSpanInUse) return false; @@ -418,8 +417,7 @@ flushptrbuf(PtrTarget *ptrbuf, PtrTarget **ptrbufpos, Obj **_wp, Workbuf **_wbuf // (Manually inlined copy of MHeap_LookupMaybe.) k = (uintptr)obj>>PageShift; x = k; - if(sizeof(void*) == 8) - x -= (uintptr)arena_start>>PageShift; + x -= (uintptr)arena_start>>PageShift; s = runtime_mheap->map[x]; if(s == nil || k < s->start || k - s->start >= s->npages || s->state != MSpanInUse) continue; @@ -466,8 +464,7 @@ flushptrbuf(PtrTarget *ptrbuf, PtrTarget **ptrbufpos, Obj **_wp, Workbuf **_wbuf // Ask span about size class. // (Manually inlined copy of MHeap_Lookup.) x = (uintptr)obj >> PageShift; - if(sizeof(void*) == 8) - x -= (uintptr)arena_start>>PageShift; + x -= (uintptr)arena_start>>PageShift; s = runtime_mheap->map[x]; PREFETCH(obj); @@ -585,8 +582,7 @@ checkptr(void *obj, uintptr objti) if(t == nil) return; x = (uintptr)obj >> PageShift; - if(sizeof(void*) == 8) - x -= (uintptr)(runtime_mheap->arena_start)>>PageShift; + x -= (uintptr)(runtime_mheap->arena_start)>>PageShift; s = runtime_mheap->map[x]; objstart = (byte*)((uintptr)s->start<sizeclass != 0) { diff --git a/libgo/runtime/mheap.c b/libgo/runtime/mheap.c index b4d94b6..af46bfb 100644 --- a/libgo/runtime/mheap.c +++ b/libgo/runtime/mheap.c @@ -150,8 +150,7 @@ HaveSpan: runtime_MSpan_Init(t, s->start + npage, s->npages - npage); s->npages = npage; p = t->start; - if(sizeof(void*) == 8) - p -= ((uintptr)h->arena_start>>PageShift); + p -= ((uintptr)h->arena_start>>PageShift); if(p > 0) h->map[p-1] = s; h->map[p] = t; @@ -169,8 +168,7 @@ HaveSpan: s->elemsize = (sizeclass==0 ? s->npages<types.compression = MTypes_Empty; p = s->start; - if(sizeof(void*) == 8) - p -= ((uintptr)h->arena_start>>PageShift); + p -= ((uintptr)h->arena_start>>PageShift); for(n=0; nmap[p+n] = s; return s; @@ -241,8 +239,7 @@ MHeap_Grow(MHeap *h, uintptr npage) mstats.mspan_sys = h->spanalloc.sys; runtime_MSpan_Init(s, (uintptr)v>>PageShift, ask>>PageShift); p = s->start; - if(sizeof(void*) == 8) - p -= ((uintptr)h->arena_start>>PageShift); + p -= ((uintptr)h->arena_start>>PageShift); h->map[p] = s; h->map[p + s->npages - 1] = s; s->state = MSpanInUse; @@ -259,8 +256,7 @@ runtime_MHeap_Lookup(MHeap *h, void *v) uintptr p; p = (uintptr)v; - if(sizeof(void*) == 8) - p -= (uintptr)h->arena_start; + p -= (uintptr)h->arena_start; return h->map[p >> PageShift]; } @@ -281,8 +277,7 @@ runtime_MHeap_LookupMaybe(MHeap *h, void *v) return nil; p = (uintptr)v>>PageShift; q = p; - if(sizeof(void*) == 8) - q -= (uintptr)h->arena_start >> PageShift; + q -= (uintptr)h->arena_start >> PageShift; s = h->map[q]; if(s == nil || p < s->start || p - s->start >= s->npages) return nil; @@ -332,8 +327,7 @@ MHeap_FreeLocked(MHeap *h, MSpan *s) // Coalesce with earlier, later spans. p = s->start; - if(sizeof(void*) == 8) - p -= (uintptr)h->arena_start >> PageShift; + p -= (uintptr)h->arena_start >> PageShift; if(p > 0 && (t = h->map[p-1]) != nil && t->state != MSpanInUse) { tp = (uintptr*)(t->start<