Date: Thu, 11 May 2000 09:26:59 -0400 (EDT) Message-Id: <200005111326.JAA13160@indy.delorie.com> From: Eli Zaretskii To: Martin Str|mberg CC: djgpp-workers AT delorie DOT com In-reply-to: <200005101802.UAA25956@father.ludd.luth.se> (message from Martin Str|mberg on Wed, 10 May 2000 20:02:24 +0200 (MET DST)) Subject: Re: Perfomance of gc-simple References: <200005101802 DOT UAA25956 AT father DOT ludd DOT luth DOT se> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: Martin Str|mberg > Date: Wed, 10 May 2000 20:02:24 +0200 (MET DST) > > Ok, I tried it on grep. Alas the configure script doesn't find my > mmap, as the MAP_FIXED option can't be supported, but the test program > uses it. > > Advice? It seems that MAP_FIXED is used when the address passed to mmap is already allocated by some prior call. (The test program in the configure script uses malloc to allocate that buffer before it calls mmap.) Can someone confirm if this is true in general? If malloc is always called before mmap(...MAP_FIXED...), then you will need to scan the data structures maintained by malloc and find the buffer whose address includes the address passed to mmap. Then use that address, after filling it with file's data. This will obviously lose if the size passed to mmap is larger than the initial allocation via malloc. Hmm. It's possible that MAP_FIXED cannot be supported in such a case; if many users of mmap need MAP_FIXED, perhaps this is a show stopper... Btw, how is this implemented on Unix/Linux? Here's the relevant fragment from the test program run by Grep's configure script: fd = open("conftestmmap", O_RDWR); if (fd < 0) exit(1); data2 = malloc(2 * pagesize); if (!data2) exit(1); data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1); if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0L)) exit(1); This expects mmap to return the same address as malloc did (modulo the alignment). Since, as DJ explained, mmap uses specially-mapped memory that can be grown at will without relocating, does this mean that mmap has to fiddle with the page tables to move the buffer to another physical address while keeping its logical address unchanged?