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

Thomas Stuefe stuefe at openjdk.java.net
Thu Oct 28 05:27:09 UTC 2021


On Thu, 28 Oct 2021 02:50:37 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> src/hotspot/share/memory/metaspace/virtualSpaceList.cpp line 193:
>> 
>>> 191: bool VirtualSpaceList::contains(const MetaWord* p) const {
>>> 192:   // Note: needs to work without locks.
>>> 193:   const VirtualSpaceNode* vsn = Atomic::load_acquire(&_first_node);
>> 
>> I believe vsn->next() now also requires load_acquire semantics.
>
> The internal nodes are already protected by the acquire/release semantics used for accessing `_first_node`, which is the only mutable field.

That's what I figured too. 

Also, if that were wrong we would have the same problem in CLDG. Where, in contrast to this list nodes get deleted too (see ClassLoaderDataGraph::clear_claimed_marks()).

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

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


More information about the hotspot-runtime-dev mailing list