RFR: JDK-8313319: [linux] mmap should use MAP_FIXED_NOREPLACE if available
Johan Sjölen
jsjolen at openjdk.org
Tue Aug 8 08:50:31 UTC 2023
On Sun, 6 Aug 2023 17:09:41 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
> os::attempt_reserve_memory_at() is used to map memory at a specific address that we fancy. It is not used to replace an existing mapping (hence we omit MAP_FIXED).
>
> But it may result in the kernel creating a mapping at a different address if our wish address is blocked; we then have to unmap again. That mmap-munmap cycle is unnecessary.
>
> MAP_FIXED_NOREPLACE exists since Linux 4.17 and prevents that unnecessary cycle . We should use that if available.
Hi,
Thanks for this and looks good to me. Two small nits.
src/hotspot/os/linux/os_linux.cpp line 3497:
> 3495: //
> 3496: // Backward compatibility: Older kernels will ignore the unknown flag; so mmap will behave
> 3497: // as in mode (a).
Is this in case of a libc that's more up to date than the kernel?
test/hotspot/gtest/runtime/test_os.cpp line 945:
> 943: os::release_memory(p1, M);
> 944: } else {
> 945: tty->print_cr("Skipped.");
Have you succesfully seen this printed? AFAIK Gtest only prints stderr by default
-------------
Marked as reviewed by jsjolen (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15170#pullrequestreview-1566808133
PR Review Comment: https://git.openjdk.org/jdk/pull/15170#discussion_r1286806000
PR Review Comment: https://git.openjdk.org/jdk/pull/15170#discussion_r1286809194
More information about the hotspot-runtime-dev
mailing list