RFR: 8362276: NMT tests should have locks for the entire tests [v2]

Aleksey Shipilev shade at openjdk.org
Wed Jul 16 11:25:44 UTC 2025


On Wed, 16 Jul 2025 11:17:27 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Gerard Ziemski has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   restructure code to make sure we use the lock as needed
>
> test/hotspot/gtest/runtime/test_virtualMemoryTracker.cpp line 441:
> 
>> 439:     ReservedSpace rs = MemoryReserver::reserve(size, mtTest);
>> 440: 
>> 441:     RegionsTree* rtree = VirtualMemoryTracker::Instance::tree();
> 
> I have to confess to not paying attention to this change, but shouldn't you fetch the tree under the lock also?

I wondered the same, but this just returns an (unchanging) pointer. We are not in this locking game to ensure memory ordering, we only need mutual exclusion here. So IMO it does not matter for correctness whether we pull this under the lock or not.

Would be cleaner to do _everything_ under the lock, but this seems fine as well.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26324#discussion_r2210066296


More information about the hotspot-runtime-dev mailing list