RFR: 8253638: Cleanup os::reserve_memory and remove MAP_FIXED [v2]

Stefan Karlsson stefank at openjdk.java.net
Mon Sep 28 06:32:57 UTC 2020


> There's a code path through os::reserve_memory that uses MAP_FIXED. This path is used if a requested address is given.
> It's very dangerous to use MAP_FIXED, since it causes pre-existing mappings to be replaced. Alternative, move safe,
> functions exists; named os_attempt_reserve_memory_at.  It's not only dangerous to use that API, the Mac AARCH64 port
> also can't use it in conjunction with its MAP_JIT.
> I started to split os::reserve_memory into two functions; one that doesn't care about were the memory is mapped
> (os::reserve_memory), and another that uses the dangerous MAP_FIXED flag (os::reserve_memory_at). However, I noticed
> that it's only windows code that actually use os::reserve_memory with a requested address. All other usages have been
> cleaned out and replaced with os::attempt_reserve_memory. And on windows os::attempt_reserve_memory uses
> os::reserve_memory with comments that it's safe because it only "attempts" to place the mapping.  So, this patch: 1)
> Removes the forcefully reserving of memory and its MAP_FIXED usages! 2) Changes the windows code to call the
> attempt_reserve_memory_at version, that it actually did anyway. 3) Flips the call order between pd_reserve_memory and
> pd_attempt_reserve_memory_at, on windows. 4) There's also some unification and split done to handle MEMFLAGS and fds.
> This part needs followup cleanups (IMHO). 5) The AIX implementation already refused to use MAP_FIXED, and now it
> doesn't need special code to handle that. 6) Small cleanups around anon_mmap and anon_mmap_aligned

Stefan Karlsson has updated the pull request incrementally with one additional commit since the last revision:

  Review 1

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/357/files
  - new: https://git.openjdk.java.net/jdk/pull/357/files/fba49d17..0b0ba20a

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=357&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=357&range=00-01

  Stats: 4 lines in 2 files changed: 2 ins; 0 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/357.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/357/head:pull/357

PR: https://git.openjdk.java.net/jdk/pull/357


More information about the hotspot-dev mailing list