PCH support on Solaris
Bonzini
bonzini@gnu.org
Thu Apr 3 07:06:00 GMT 2003
> The reporter of PR other/9830 proposes to force the address by passing
> MAP_FIXED to mmap; this works (all pch tests of the testsuite pass) but, if
> my interpretation is correct, this could fail if the pages before the forced
> address are for some reason unmappable.
No, instead, it will overwrite the previous map on most systems. From the Linux man
pages
The MAP_FIXED option informs the system that the [returned]
value must be addr, exactly. The use of MAP_FIXED is
discouraged, as it may prevent an implementation from
making the most effective use of system resources.
When MAP_FIXED is set and the requested address is the
same as previous mapping, the previous address is unmapped
and the new mapping is created on top of the old one.
A solution might be to do an anonymous mmap to find the address
#ifndef MAP_NORESERVE
#define MAP_NORESERVE 0
#endif
guess = mmap (mmi.preferred_base, mmi.size,
PROT_NONE, MAP_PRIVATE|MAP_NORESERVE|MAP_ANON,
-1, 0);
addr = mmap (guess, mmi.size, PROT_READ, MAP_FIXED|MAP_SHARED,
fd, mmi.offset);
>From the same source:
The MAP_NORESERVE option specifies that no swap space
be reserved for a mapping. Without this flag, the creation of a
writable MAP_PRIVATE mapping reserves swap space equal to
the size of the mapping; when the mapping is written into, the
reserved space is employed to hold private copies of the data.
In theory, a non-writable MAP_PRIVATE mapping does not reserve swap space (which is why
I always define MAP_NORESERVE above) but I think it's better to use MAP_NORESERVE just
in case.
Paolo
More information about the Gcc-patches
mailing list