From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rasif-0007Z0-Bx for qemu-devel@nongnu.org; Wed, 14 Dec 2011 12:34:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rasid-00073y-E1 for qemu-devel@nongnu.org; Wed, 14 Dec 2011 12:34:17 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:44253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rasid-00073o-6K for qemu-devel@nongnu.org; Wed, 14 Dec 2011 12:34:15 -0500 From: Paul Brook Date: Wed, 14 Dec 2011 17:34:08 +0000 References: <1323725761-5629-1-git-send-email-agraf@suse.de> <201112141204.45646.paul@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201112141734.09301.paul@codesourcery.com> Subject: Re: [Qemu-devel] [PATCH] PPC: Fix linker scripts on ppc hosts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Riku Voipio , Richard Henderson , "dvaleev@suse.com" , Alexander Graf , "qemu-devel@nongnu.org" > >> The proper solution would be to rewrite mmap.c to be smarter (perhaps > >> by looking at /proc/self/maps and reserving a lot of space with > >> PROT_NONE mappings at startup and then managing it itself), but so far > >> nobody's done that > > > > Yes they have. That's what -R does. > > -R doesn't happen by default, it requires you to specify how much you > want, and it insists that the space all be in one chunk. I've covered the defaults elsewhere in this thread. If your 64-bit host can't find a contiguous 4G block of address space then you've much more serious issues. System policies preventing applications allocating that much address space are a different problem, and splitting the into chunks would not help. > > We used to try and parse /proc/self/maps. This caused more problems than > > it solved. It doesn't cover things like mmap_min_addr, and you have to > > re-parse it before every allocation in case the host libc allocated > > something new in between. > > If you've used a PROT_NONE mapping to claim the space at startup, host libc > doesn't override that mapping, does it? Ah, I see what you mean. If you're solving problems other than 32-on-64 then there's some argument for allowing discontiguous blocks. I'm not convinced there's much point parsing /proc/self/maps though. Just keep calling mmap for sensible sized blocks until you either have enough address space or it fails. In the latter case maybe free some back immediately to give the host libc room to work. The hard bit is coming up with heuristics for "sensibe size block" and "have enough". /proc/self/maps only tells you which areas of the host VM are currently mapped. What we really want to know is which areas are available to be mapped. On 32-bit hosts this may be this may be less than half of the gaps in /proc/self/maps. On 64-bit hosts it's many orders of magnitude smaller. For example x86-64 only has 47-bits of usable virtual address space. Nested qemu is also going to make a complete mess of /proc/self/maps, though I admit you're probably going to trip over other bugs first :-) Paul