From patchwork Tue Jun 27 22:36:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 781405 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wy1523jzxz9s72 for ; Wed, 28 Jun 2017 08:37:10 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bQRSB5g2"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=vJswNh/Drjz284d8i1Fh3bKLH7CqQ//T2IXR64TtW4MIKJ vaUqPPpwpelUgbB163hA62yJ+HqBmYviKH0sHbvhZIo6TrlGf+tg6K6osgYVkW0D NoX0qCn7DV2bJ0fVMYQCyT4G+4wqHu+TZNHTurgqXSX7kO+cSc7Ywizkwmw3E= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=pNHgTr857Wmalcqqb2nteYZZ0O8=; b=bQRSB5g2N8tU74JJHKc6 /aKYAKFMBccS2kP/czUKy7sPmM7WXMiLIna1Dl+3cwN3mnKlpDpPbkbn6TubHw2m dp+0ZAikLivt7UYtSmD5Uq4s9vrCer8ojt8Ig0vOOOKHMQmb0dQIpNsvLL1dL2ef J4WVX9S5zma92lhleoNCaXY= Received: (qmail 102212 invoked by alias); 27 Jun 2017 22:36:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk 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 102203 invoked by uid 89); 27 Jun 2017 22:36:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=reserved, management X-HELO: mail-oi0-f53.google.com Received: from mail-oi0-f53.google.com (HELO mail-oi0-f53.google.com) (209.85.218.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Jun 2017 22:36:56 +0000 Received: by mail-oi0-f53.google.com with SMTP id l83so28820989oif.1 for ; Tue, 27 Jun 2017 15:36:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=0ejghep3WS94Uey2uHucfAoNR+ftMqnxg6RcGjXcPsk=; b=gZWe5DD3n0QUokvDAvfOWA1/OE29C4YdPz7Ty73I36Hxt8eO5CbrK+l7/+tEOZuR6m xrHIM9LaWcdyQBSSbgSZh7sWMoiVGmBPABLonvJ5FMJlq37IOKKw9LCDbfvbKznZgnOj mCXvhpeq9bLF/XBTuBROux4bQ7aecU8EB9ANKNeWvP47gso0ZeIj1BmnCQZ2pJEyEWoc 0nna+69X8BSXcEdHcwFyL92O6Iw7miUxO+gCdB28OOjUlf0/00O3EgH93E4h0c0Bclun GA0kJQ8nO/ZRVw8lqGC6eXYo7HJnWcnK00QAqfxCJDRhLJkQNeitfeg28q9RFp746CNE deeg== X-Gm-Message-State: AKS2vOyxzgRcX7xjg3EZ0aQgBplcwqqrrd3HrX/arG4wyUdiluwpcr0f v17NGwNBZvrwn9K/4id7GbAfuckb3rc1r48= X-Received: by 10.202.225.9 with SMTP id y9mr5208977oig.32.1498603014747; Tue, 27 Jun 2017 15:36:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.189.11 with HTTP; Tue, 27 Jun 2017 15:36:54 -0700 (PDT) From: Ian Lance Taylor Date: Tue, 27 Jun 2017 15:36:54 -0700 Message-ID: Subject: libgo patch committed: AIX memory management To: gcc-patches , "gofrontend-dev@googlegroups.com" On AIX: * mmap does not allow to map an already mapped range, * mmap range start at 0x30000000 for 32 bits processes, * mmap range start at 0x70000000_00000000 for 64 bits processes This libgo patch by Matthieu Sarter addresses these issues. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 249712) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -63b766d67098877496a4b79d7f41e731fbe8abc8 +66d14d95a5a453682fe387319c80bc4fc40d96ad The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/malloc.go =================================================================== --- libgo/go/runtime/malloc.go (revision 249205) +++ libgo/go/runtime/malloc.go (working copy) @@ -291,6 +291,8 @@ func mallocinit() { // allocation at 0x40 << 32 because when using 4k pages with 3-level // translation buffers, the user address space is limited to 39 bits // On darwin/arm64, the address space is even smaller. + // On AIX, mmap adresses range start at 0x07000000_00000000 for 64 bits + // processes. arenaSize := round(_MaxMem, _PageSize) bitmapSize = arenaSize / (sys.PtrSize * 8 / 2) spansSize = arenaSize / _PageSize * sys.PtrSize @@ -301,12 +303,15 @@ func mallocinit() { p = uintptr(i)<<40 | uintptrMask&(0x0013<<28) case GOARCH == "arm64": p = uintptr(i)<<40 | uintptrMask&(0x0040<<32) + case GOOS == "aix": + i = 1 + p = uintptr(i)<<32 | uintptrMask&(0x70<<52) default: p = uintptr(i)<<40 | uintptrMask&(0x00c0<<32) } pSize = bitmapSize + spansSize + arenaSize + _PageSize p = uintptr(sysReserve(unsafe.Pointer(p), pSize, &reserved)) - if p != 0 { + if p != 0 || GOOS == "aix" { // Useless to loop on AIX, as i is forced to 1 break } } Index: libgo/go/runtime/mem_gccgo.go =================================================================== --- libgo/go/runtime/mem_gccgo.go (revision 249205) +++ libgo/go/runtime/mem_gccgo.go (working copy) @@ -270,6 +270,11 @@ func sysMap(v unsafe.Pointer, n uintptr, return } + if GOOS == "aix" { + // AIX does not allow mapping a range that is already mapped. + // So always unmap first even if it is already unmapped. + munmap(v, n) + } p := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, mmapFD, 0) if uintptr(p) == _MAP_FAILED && errno() == _ENOMEM { throw("runtime: out of memory") Index: libgo/runtime/runtime_c.c =================================================================== --- libgo/runtime/runtime_c.c (revision 249205) +++ libgo/runtime/runtime_c.c (working copy) @@ -139,6 +139,10 @@ uintptr getEnd(void) uintptr getEnd() { +#ifdef _AIX + // mmap adresses range start at 0x30000000 on AIX for 32 bits processes + uintptr end = 0x30000000U; +#else uintptr end = 0; uintptr *pend; @@ -146,6 +150,8 @@ getEnd() if (pend != nil) { end = *pend; } +#endif + return end; }