Using mmap(2) with a hint address
tijl at coosemans.org
Tue Dec 20 17:45:22 UTC 2011
On Tuesday 20 December 2011 15:31:48 Ganael LAPLANCHE wrote:
> On Tue, 20 Dec 2011 15:02:01 +0100 (CET), Ganael LAPLANCHE wrote
>> But there is still something I don't understand : on the Linux
>> machine where I ran my test program, the current RLIMIT_DATA
>> is set to 0xffffffff/0xffffffff and I can manage to mmap at
>> address 0x20000000. If I set the same limit on FreeBSD, I
>> won't get the mapping at 0x20000000. So, there *is* a
>> difference of behaviour between the two systems, but I don't
>> understand why.
> Well, in fact, two things remain not very clear for me :
> - Why are mmap()s performed *after* data segment ?
> => It seems they can go within, on GNU/Linux and NetBSD.
I don't know about NetBSD but Linux maps from the stack downwards when
there's no hint and FreeBSD maps from the program upwards. That means
that on Linux brk and mmap grow toward each other and unless you
allocate a lot of memory they don't compete with each other. On FreeBSD
brk and mmap do compete for the same space and this was resolved by
preserving room for brk and moving mmap allocations further up.
The case with hint lazily follows from that. Linux doesn't have any
restrictions and FreeBSD preserves room for brk and moves the
> - Why do we have such a default value for datasize (8.2, amd64) :
> $ limits
> Resource limits (current):
> cputime infinity secs
> filesize infinity kB
> datasize 33554432 kB
> this is HUGE !
malloc(3) used to be implemented on top of brk(2) so the size was
increased on amd64 so you could malloc more memory. Nowadays malloc
can use mmap(2) so a large datasize isn't really needed anymore.
That should be "-- " (with space at the end).
> Ganael LAPLANCHE <ganael.laplanche at martymac.org>
> http://www.martymac.org | http://contribs.martymac.org
> FreeBSD: martymac <martymac at FreeBSD.org>, http://www.FreeBSD.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 228 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20111220/2ae91ba3/attachment.pgp
More information about the freebsd-stable