maximum mmap()

Tijl Coosemans tijl at ulyssis.org
Wed May 13 19:28:11 UTC 2009


On Wednesday 13 May 2009 16:11:44 John Baldwin wrote:
> On Wednesday 13 May 2009 7:10:29 am dikshie wrote:
>> i found that my rrdtool does not work with mmap() with rra files
>> size more than 2GB.
>> my question: on i386 arch,  what's maximum size of file to be able
>> to mmap() ? do i have to change from i386 to amd64? or added 4GB
>> RAM?
> 
> The amount of RAM is not the issue, it is the size of the virtual
> address space.  You can lower maxdsiz on i386 to leave more room for
> mmap, and you can also change KVA_PAGES in the kernel to leave more
> address space for userland than for the kernel perhaps, but you won't
> get a whole lot more space that way (you might be able to map 2.5GB
> or so).  Moving to amd64 gives you a 64-bit virtual address space and
> you will be able to easily mmap() much, much more than 4GB out of the
> box.

On a default i386 system it should be possible to mmap files larger
then 2GiB, but for some reason mmap treats sizes above 0x7fffffff as an
error and returns EINVAL:

        if ((ssize_t) uap->len < 0 ||
            ((flags & MAP_ANON) && uap->fd != -1))
                return (EINVAL);

The only way around this is to mmap the entire file with two mmap
calls.


More information about the freebsd-stable mailing list