From owner-freebsd-hackers@freebsd.org Sat Nov 19 06:58:04 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F4F4C49A0F for ; Sat, 19 Nov 2016 06:58:04 +0000 (UTC) (envelope-from eliz@gnu.org) Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:4830:134:3::10]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 21A5FE10 for ; Sat, 19 Nov 2016 06:58:04 +0000 (UTC) (envelope-from eliz@gnu.org) Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7zb8-0002go-Cf for freebsd-hackers@freebsd.org; Sat, 19 Nov 2016 01:58:03 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7zam-0002bY-5x; Sat, 19 Nov 2016 01:57:40 -0500 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:3339 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1c7zal-0003x0-6z; Sat, 19 Nov 2016 01:57:39 -0500 Date: Sat, 19 Nov 2016 08:57:44 +0200 Message-Id: <83vavkardj.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert CC: emaste@freebsd.org, freebsd-hackers@freebsd.org, brooks@freebsd.org, 24892@debbugs.gnu.org, ashish.is@lostca.se In-reply-to: <1dc6fa8c-7378-6e4e-1d9e-86c962fc48bb@cs.ucla.edu> (message from Paul Eggert on Fri, 18 Nov 2016 14:22:07 -0800) Subject: Re: bug#24892: {s, }brk removed from FreeBSD 11.x and later, arm64 architecture Reply-to: Eli Zaretskii References: <82a03552-8f33-2dbe-6bb5-54f649b29db7@cs.ucla.edu> <86vavxs2cn.fsf@members.fsf.org> <5adee8d9-8f08-9536-a95f-ae64719d6a0f@cs.ucla.edu> <40f8df50-b431-1ebd-221c-df2aa453aa81@cs.ucla.edu> <06ee71fd-1a64-d32b-862e-c725807aef4e@cs.ucla.edu> <876cf047-82fb-f08c-bbb3-024206f6fabd@cs.ucla.edu> <83twb6dnkm.fsf@gnu.org> <8637ipm0nb.fsf@lostca.se> <5ec481c4-41e1-c7dd-433d-f533653b132f@cs.ucla.edu> <1dc6fa8c-7378-6e4e-1d9e-86c962fc48bb@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Mailman-Approved-At: Sat, 19 Nov 2016 12:46:27 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Nov 2016 06:58:04 -0000 > From: Paul Eggert > Date: Fri, 18 Nov 2016 14:22:07 -0800 > Cc: freebsd-hackers@freebsd.org, Brooks Davis , > 24892@debbugs.gnu.org, Ashish SHUKLA > > > it seems there's an implementation that allocates memory out of a large array in .bss used for some platforms - could we make use of that here? > > Quite possibly. Unfortunately the code that uses that array (in gmalloc.c) also > uses sbrk to move the break past the end of the large array. The large array is > intended for use only during the build process; during ordinary execution, sbrk > is used. > > Perhaps Emacs could work around the problem by supplying a user-space sbrk > emulator, which uses mmap to support the old-fashioned model where the heap is > contiguous. Is that something that could be done easily? That is, is there some > way to reserve the address space for a potentially-large Emacs heap right after > .bss, such that library calls to malloc and mmap won't use this address space? > That might do the trick. > > Brooks Davis wrote: > > What does emacs actually need from sbrk()? Could it get by with something with the same interface allocating from .bss or does it need its allocations to be at the end of .bss? > > I think more the latter. The problem with a fixed-size .bss is that whatever > size we pick during the build is likely to be wrong for users. Also, Emacs saves > the entire build-time .bss into an executable, so an enormous .bss will be > counterproductive. I agree with everything Paul wrote. There's one other factor you should be aware of: Emacs 25.2 will most probably start its pretest in a week or so. If this problem can be solved for FreeBSD on arm64 by providing a drop-in replacement for sbrk, we could include that in 25.2, which is a strictly bug-fix release that can only accept safe bug fixes. If not, the solution will have to wait for Emacs 26.1, currently being developed on the master branch, which is unlikely to be released before mid-2017 or even the end of 2017. Not a catastrophe, given that Emacs never worked on this host, but something to consider. (It is, of course, possible to provide a simple and safe solution for 25.2 and a more elaborate one for 26.1.) Thanks.