RFR: 8356667: GenShen: Eliminate races with ShenandoahFreeSet::available()
Kelvin Nilsen
kdnilsen at openjdk.org
Mon May 12 23:17:51 UTC 2025
On Mon, 12 May 2025 23:05:43 GMT, William Kemper <wkemper at openjdk.org> wrote:
>> Two changes:
>>
>> 1. Compute the difference between capacity and used while holding the heap lock (so that these two values do not change in incompatible ways while the difference is being computed)
>> 2. Return a "harmless" Sentinel value in case available() is consulted while we are in the process of rebuilding the freeset. The SIZE_MAX value is considered harmless in that it will not cause immediate trigger of a new GC. In typical usage, the control or regulator thread will check available() again in another millisecond, at which time a more accurate accounting of available will be provided (if the freeset reconstruction has been completed).
>
> src/hotspot/share/gc/shenandoah/shenandoahFreeSet.hpp line 235:
>
>> 233:
>> 234: // Acquire heap lock and return available_in, assuming heap lock is not acquired by the caller.
>> 235: inline size_t available_in_under_lock(ShenandoahFreeSetPartitionId which_partition) const {
>
> This name confuses me: `available_in_under_lock`. Should it be called `available_without_lock` or `available_no_lock`? Or, switch it with `available_in` (which asserts that the heap lock is held). I see that it takes the lock, but this is only to make the assertion.
Thanks for review and comments. I'll change the name. It follows a pattern that is admittedly very confusing...
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25165#discussion_r2085656619
More information about the hotspot-gc-dev
mailing list