RFR: 8335217: Fix memory ordering in ClassLoaderData::ChunkedHandleList [v5]

David Holmes dholmes at openjdk.org
Wed Jul 3 06:50:24 UTC 2024


On Fri, 28 Jun 2024 17:02:30 GMT, Zhengyu Gu <zgu at openjdk.org> wrote:

>> ClassLoaderData::ChunkedHandleList's head is installed via Atomic::release_store(). Therefore, readers need Atomic::Atomic::load_acquire() barrier to access its members safely.
>
> Zhengyu Gu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Revert destructor change

src/hotspot/share/classfile/classLoaderData.cpp line 207:

> 205:   Chunk* chunk = Atomic::load_acquire(&_head);
> 206:   while (chunk != nullptr) {
> 207:     count += Atomic::load(&chunk->_size);

I don't think this is necessary - there is no concurrent write of this chunk's size possible whilst we read it.

src/hotspot/share/classfile/classLoaderData.cpp line 263:

> 261:   Chunk* chunk = Atomic::load_acquire(&_head);
> 262:   while (chunk != nullptr) {
> 263:     if (&(chunk->_data[0]) <= oop_handle && oop_handle < &(chunk->_data[Atomic::load(&chunk->_size)])) {

Why would need to atomically load the address of the member?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19919#discussion_r1663602089
PR Review Comment: https://git.openjdk.org/jdk/pull/19919#discussion_r1663604025


More information about the hotspot-runtime-dev mailing list