RFR: JDK-8275704: Metaspace::contains() should be threadsafe [v2]

Thomas Stuefe stuefe at openjdk.java.net
Thu Oct 28 05:33:36 UTC 2021


> Metaspace::contains() is used in many places. It is not threadsafe since it walks the list of metaspace mappings, which can be altered concurrently. This is suspected to be the cause of JDK-8271124.
> 
> Currently, it does not lock, and adding a lock is not realistic either. It should work lockless.
> 
> This patch builds atop of https://bugs.openjdk.java.net/browse/JDK-8275582, which removed the old (pre JEP 387) technique of uncommitting metaspace memory. As a side effect, that patch changed the mapping list to an add-only structure. The only remaining place where it gets modified is in VirtualSpaceList::create_node(). Modifications are synchronized via lock. The only place where we walk the list locklessly is in Metaspace::contains(). This patch adds the appropriate memory barriers to those two places.
> 
> Tests:
> - GHAs
> - SAP nightlies (queued)

Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:

  fix typo

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/6060/files
  - new: https://git.openjdk.java.net/jdk/pull/6060/files/bfe54c16..8f6e91fc

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

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6060.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6060/head:pull/6060

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


More information about the hotspot-runtime-dev mailing list