mmap behavior



The following code behaves differently between kernel 2.4 and kernel
2.6:

size_t length = 0x40000000; /* 1GB */
void *addr = mmap (0, length, PROT_NONE, MAP_SHARED|MAP_ANONYMOUS, 0,
0);

With kernel 2.4, this 1GB mapping does not account for the process' VM
size, and this is IMHO the expected behavior, since the reserved
address space is not accessible (PROT_NONE).

With kernel 2.6, the 1GB mapping accounts for the process' VM size. The
process vsize as reported in /proc/pid/statm is > 1GB and I get the
following entry in pmap output:

0000002a9557a000 1048576K ---s- /dev/zero (deleted)

Any advice?
Thanks,
Olivier.

.



Relevant Pages