Integrated: JDK-8313319: [linux] mmap should use MAP_FIXED_NOREPLACE if available
Thomas Stuefe
stuefe at openjdk.org
Thu Aug 24 05:22:00 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. We need to tiptoe around a bit to deal with building on old machines/running on old kernels, though.
This pull request has now been integrated.
Changeset: 3699666c
Author: Thomas Stuefe <stuefe at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/3699666c9325b38d287e1d4d2576f8e3a662ae81
Stats: 49 lines in 2 files changed: 47 ins; 0 del; 2 mod
8313319: [linux] mmap should use MAP_FIXED_NOREPLACE if available
Reviewed-by: jsjolen, dholmes
-------------
PR: https://git.openjdk.org/jdk/pull/15170
More information about the hotspot-runtime-dev
mailing list