Re: mmap behavior



ochedru@xxxxxxxxx wrote:
This actually causes some trouble because my application relies on
vsize to perform some self-maintenance tasks.
With this fake 1GB overhead, this mechanism is broken.

Your program is broken, because it depends on dubious or even buggy
behavior.

Is there any workaround? Is there another way to reserve an address
space range for shared mappings?

mmap doesn't reserve, it allocates.

There is no sure-fire way to reserve an address space range without
actually mapping it.

A PROT_NONE mapping is a real mapping. It's not valid for mmap to
simply not create the mapping because the protection is set to
PROT_NONE. A mapped page that cannot be read or written is not the same
thing as an unmapped page. It's a mapped page which happens not to have
write permission or read permission.

See, you can adjust the protection later with mprotect. You can't
adjust the protection on unmapped memory with mprotect. The mapping has
to exist.

Also, I could not find anything in /proc that would allow me to get the
"real" vsize.

Can't your program keep track of what it considers to be "not real" and
subtract it?

.



Relevant Pages

  • Re: Ordnance Survey fights to retain restrictive use of mapping data
    ... Britain's support for state-owned agencies Britain is threatening ... crucial to the protection of Europe's land, air and water - unless it is ... It may also be a factor that the OS started mapping the UK 100 years ... were the military map makers of the British Empire, ...
    (sci.geo.satellite-nav)
  • Re: JIT emulator needs
    ... > be a fixed offset from the read/exec mapping. ... debris when the JIT crashes. ... mremapflag to get a read/exec mapping of a read/write one ... This is all mprotect and munmap. ...
    (Linux-Kernel)
  • Re: [PATCH 1/6] mm: tracking shared dirty pages
    ... +static inline int is_shared_writable ... low four bits) to a page protection mask.. ... The only way "mapping" might be set is just above. ...
    (Linux-Kernel)
  • Re: /proc/pid/maps containg anonymous maps that have PROT_NONE
    ... Is it coming from glibc mapping memory as PROT_NONE, ... There is an mprotect and madvise that end at 0x7fffe406a000. ... don't see the mmap only the mprotect, but I used strace -f. ...
    (Linux-Kernel)
  • Re: Linux in Forth?
    ... You can have POSIX-like protection, if you separate the protection from the ... but only those parts he's able to read (r/o mapping) and write (r/w ... With a page granularity of mapping, ... chmod'ing whole directory trees however can be cheaper, ...
    (comp.lang.forth)