On Thu, 18 May 2023 12:41:49 GMT, Paul Hohensee <p...@openjdk.org> wrote:

>> src/hotspot/share/services/threadService.hpp line 113:
>> 
>>> 111:     // No need for atomicity, method is called under the Threads_lock
>>> 112:     _exited_allocated_bytes += size;
>>> 113:   }
>> 
>> As there is a lock-free read however you need to use Atomic::load and 
>> Atomic::store - especially for 32-bit systems.
>
> Changed. Not sure atomic load is needed.

Even though this version passed the pre-submit tests, which include the new 
versions of ThreadAllocatedBytes.java, running it more often on a host with 
many hardware threads resulted in failures where getTotalAllocatedBytes did not 
monotonically increase. I believe what happened was that without an 
acquire/release, the hardware can float earlier stores to 
_exited_allocated_bytes above later ones. Adding acquire/release fixed the 
issue.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13814#discussion_r1197862479

Reply via email to