That sounds like a fine approach. I wonder if the behaviour is different<br>on 32bit FreeBSD. I'll check it for the sake of interest. I wont be able<br>to dig too deep into it before the 1st I think but then it gets a round of
<br>work. I hope to get the runtime to run then.<br><br><br><br><div><span class="gmail_quote">On 6/27/07, <b class="gmail_sendername">Matthew Fluet</b> <<a href="mailto:fluet@tti-c.org">fluet@tti-c.org</a>> wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Matthew Fluet wrote:<br>> Jesper Louis Andersen wrote:<br>>> Matthew is right, it doesn't cycle. I came to the same conclusion
<br>>> independently<br>>> of him. What nags me however is that since we are not doing MAP_FIXED the<br>>> location is a hint to the kernel. In principle the kernel is free to<br>>> provide<br>>> us with
<br>>> any memory area where it can fit the mapping.<br>><br>> That appears to be how things work on linux. There, we request an mmap<br>> at the address 0xf800000000000000 and are returned an mmap at the<br>
> address 0x00002aaaaaab2000.<br>><br>> I thought that I read somewhere that mmap would return a higher addresss<br>> than the one requested, but not a lower address. Maybe that is what is<br>> happening on FreeBSD. It certainly isn't the case on Linux.
<br>><br>> But, presumably, there was some reason to put in the scan through<br>> memory. As Jesper notes, one expects that without MAP_FIXED, we should<br>> get back an address if there is enough space.<br><br>
I looked back through the SVN/CVS logs. The mmap scan was added at<br>revision 834 (Feb. 5, 2002); the commit log indicates that it was a<br>PolySpace runtime modification, mostly for performance improvements.<br>A few days later, a comment was added to the code explaining that "This
<br>toggles back and forth between high and low addresses to decrease the<br>chance of virtual memory fragmentation causing an mmap to fail. This is<br>important for large (>1G) heaps."<br><br>We have never used MAP_FIXED as an option to mmap. Googling for mmap
<br>man pages doesn't reveal any well-defined behavior of mmap (without<br>MAP_FIXED) in the presence of a hint address.<br><br>In any case, I'll change the code to compute a scan stride equal to 1/32<br>of the address space. That will give the same behavior on 32-bit
<br>systems, and will presumably get us quickly to a successful mmap on<br>64-bit systems that interpret the hint more strictly than linux.<br><br><br>_______________________________________________<br>MLton mailing list<br>
<a href="mailto:MLton@mlton.org">MLton@mlton.org</a><br><a href="http://mlton.org/mailman/listinfo/mlton">http://mlton.org/mailman/listinfo/mlton</a><br><br></blockquote></div><br>