RFR: 8361099: Shenandoah: Improve heap lock contention by using CAS for memory allocation [v5]

Xiaolong Peng xpeng at openjdk.org
Fri Nov 7 19:42:31 UTC 2025


On Wed, 5 Nov 2025 19:00:37 GMT, Kelvin Nilsen <kdnilsen at openjdk.org> wrote:

>> src/hotspot/share/gc/shenandoah/shenandoahFreeSet.cpp line 848:
>> 
>>> 846: HeapWord* ShenandoahFreeSet::allocate_with_affiliation(Iter& iterator, ShenandoahAffiliation affiliation, ShenandoahAllocRequest& req, bool& in_new_region) {
>>> 847:   for (idx_t idx = iterator.current(); iterator.has_next(); idx = iterator.next()) {
>>> 848:     ShenandoahHeapRegion* r = _heap->get_region(idx);
>> 
>> I wonder if we could refine this a little bit.  When the region is moved into the "directly allocatable" set, wouldn't we remove it from its partition?  Then, we wouldn't have to test for !r->reserved_for_direct_allocation() here because the iterator wouldn't produce it. 
>> 
>> We could maybe replace this test with an assert that !r->reserved_for_direct_allocation().
>
> Same issue in other uses of the allocation iterator.

You are right, allocate_with_affiliation is only called from collector, it won't see any regions from Mutator partition, we don't even need to the assert here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26171#discussion_r2505191139


More information about the hotspot-gc-dev mailing list