RFR: 8356667: GenShen: Eliminate races with ShenandoahFreeSet::available()
William Kemper
wkemper at openjdk.org
Mon May 12 23:09:53 UTC 2025
On Fri, 9 May 2025 23:45:50 GMT, Kelvin Nilsen <kdnilsen 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).
Minor nits.
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.
src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp line 242:
> 240: }
> 241:
> 242: ShenandoahGenerationalHeap::TransferResult result;;
Extra `;` here.
-------------
Changes requested by wkemper (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/25165#pullrequestreview-2834801227
PR Review Comment: https://git.openjdk.org/jdk/pull/25165#discussion_r2085650563
PR Review Comment: https://git.openjdk.org/jdk/pull/25165#discussion_r2085648309
More information about the hotspot-gc-dev
mailing list