RFR: 8325108: POSIX map_memory_to_file calls release_memory unnecessarily
Coleen Phillimore
coleenp at openjdk.org
Thu Jan 8 18:16:27 UTC 2026
On Wed, 7 Jan 2026 09:16:57 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:
> The implementation of the function os::map_memory_to_file calls os::release_memory if a mmap:ing to a fixed location succeeds but is not at the requested location. A POSIX implementation of mmap is not allowed to succeed and return a different base address if `MAP_FIXED` is supplied, so this is dead code. We can remove it.
>
> Quote:
>
>>When MAP_FIXED is set in the flags argument, the implementation is informed that the value of pa shall be addr, exactly. If MAP_FIXED is set, mmap() may return MAP_FAILED and set errno to [EINVAL]. If a MAP_FIXED request is successful, the mapping established by mmap() replaces any previous mappings for the process' pages in the range [pa,pa+len).
>
> https://pubs.opengroup.org/onlinepubs/009604499/functions/mmap.html
src/hotspot/os/posix/os_posix.cpp line 460:
> 458: return nullptr;
> 459: }
> 460: if (base != nullptr && addr != base) {
Can you turn this into an assert with a comment in the assert string why this isn't possible?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29081#discussion_r2673373919
More information about the hotspot-runtime-dev
mailing list