NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mmap and MAP_FIXED



On 2016-05-12 16:33, Michael wrote:
Hello,

On Thu, 12 May 2016 11:26:08 +0200
Johnny Billquist <bqt%update.uu.se@localhost> wrote:

I haven't tested, or analyzed this to any depth, but I wonder... What is
the pagesize of the machine? 8K? I wonder if you might have some issue
when you try to map only 4K fixed. The man-page says that if MAP_FIXED
is used, the address must be page aligned, but it does not say anything
about the size, but it makes me wonder...

Page size is hardware dependent, I have machines here that use 4K
( sparc, powerpc, etc. ), 8K ( sparc64, arm ) or 16K ( some MIPS )
pages.
But the start address in the test program is aligned to something much
larger, so the first test should succeed if that was the problem. I
wouldn't bet on the address range used being available though, but
that's just a hunch.

Uh, my point was that the mmap call is only requesting a 4K-sized map, which I wonder what could be the effect on a machine with a larger page size, and an anonymous mapping with a fixed address.

Also, why MMAP_FIXED in the first place?

That is a different question, but a very good one. In general, I think it's a bad idea to try and force the address.

Finally, mmap()ing 1TB will probably run into all sorts of other
problems before hitting mmap() itself. If the underlying filesystem is
ffsv1 it probably doesn't even support files that big.

You commented yourself on this later, the size is actually only 4K, and not 1TB. :-)
Also, note that there is no underlying file system in this case.

	Johnny



Home | Main Index | Thread Index | Old Index