RFR: 8353184: ZGC: Simplify and correct tlab_used() tracking [v4]

Stefan Johansson sjohanss at openjdk.org
Fri May 9 07:52:53 UTC 2025


On Thu, 8 May 2025 15:57:19 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

>> Stefan Johansson has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Handle inc and dec in alloc/undo
>
> src/hotspot/share/gc/z/zTLABUsage.cpp line 43:
> 
>> 41: 
>> 42: void ZTLABUsage::reset() {
>> 43:   const size_t current_used = Atomic::xchg(&_used, (size_t) 0);
> 
> Does this work instead?
> Suggestion:
> 
>   const size_t current_used = Atomic::xchg(&_used, 0u);

No, `0ul` works on Linux, but Windows fails with that.

> src/hotspot/share/gc/z/zTLABUsage.cpp line 51:
> 
>> 49: 
>> 50:   // Save the old values for logging
>> 51:   const size_t old_used = used();
> 
> It's not immediately obvious what `_used` is compared to `used()` Could one of these be renamed so that readers don't mistakenly assume that `used()` returns `_used`.

Talked a bit about this offline, will add some comments and rename `used()` and `capacity()` to `tlab_used()` and `tlab_capacity()` to make it a bit more clear that they are not directly connected and also better match the `ZHeap` interface.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24814#discussion_r2081127733
PR Review Comment: https://git.openjdk.org/jdk/pull/24814#discussion_r2081130690


More information about the hotspot-gc-dev mailing list