RFR: 8354929: Update collection stats while holding page allocator lock

Stefan Karlsson stefank at openjdk.org
Thu Apr 17 11:26:51 UTC 2025


On Thu, 17 Apr 2025 10:48:54 GMT, Stefan Johansson <sjohanss at openjdk.org> wrote:

> Please review this change to restructure some code in the mark start pause to do updates while holding the lock.
> 
> **Summary**
> We currently update the collection high and low used values during the mark start pause without taking the page allocator lock. This is fine since it is read atomically, but consistency verification in this code requires the lock to be held. We later in the pause take the lock to get the current statistics, this change moves the update code to also happen while holding the lock. 
> 
> I've renamed `reset_statistics()` to `update_collection_stats()` to better match what it actually does and made it private. 
> 
> **Testing**
> Mach5 tier1-5

Looks good. I've add a couple of suggestions for blank lines.

src/hotspot/share/gc/z/zPageAllocator.cpp line 1378:

> 1376: void ZPageAllocator::update_collection_stats(ZGenerationId id) {
> 1377:   assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint");
> 1378: #ifdef ASSERT

Suggestion:


#ifdef ASSERT

src/hotspot/share/gc/z/zPageAllocator.cpp line 1388:

> 1386:   assert(total_used == _used, "Must be consistent at safepoint %zu == %zu", total_used, _used);
> 1387: #endif
> 1388:   _collection_stats[(int)id]._used_high = _used;

Suggestion:


  _collection_stats[(int)id]._used_high = _used;

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

Marked as reviewed by stefank (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/24719#pullrequestreview-2775405882
PR Review Comment: https://git.openjdk.org/jdk/pull/24719#discussion_r2048745637
PR Review Comment: https://git.openjdk.org/jdk/pull/24719#discussion_r2048745371


More information about the hotspot-gc-dev mailing list