RFR: 8352588: GenShen: Enabling JFR asserts when getting GCId [v5]

Xiaolong Peng xpeng at openjdk.org
Mon Mar 24 19:21:23 UTC 2025


> ### Root cause
> Shenandoah has its own way to generate gc id([link](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp#L234), [link](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/gc/shenandoah/shenandoahController.hpp#L43)), but when it runs a specific GC cycle, it still use the default GCIdMark([link](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/gc/shenandoah/shenandoahGenerationalControlThread.cpp#L389)) to generate a gc id and set it to NamedThread::_gc_id. Once the specific GC cycle finishes, the NamedThread::_gc_id is restored to the original value which is `undefined`, which causes the asserts when Enabling JFR, in release build it should cause invalid GC id in some of JFR events.
> 
> ### Solution
> it is confusing that Shenandoah generates its own gc id but not use it for GC logging and JFR, the solution is fairly simple, the control thread just need inject gc id with GCIdMark(gc_id) it generates in `ShenandoahControlThread::run_service` and `ShenandoahGenerationalControlThread::run_gc_cycle`
> 
> In the test, I also noticed the value of gc_id generated by Shenandoah control thread starts from 1, which is different from the default behavior of GCIdMark which generates id starting from 0, this PR will also fix it.  
> 
> ### Test
> - [x] TEST=gc/shenandoah/TestWithLogLevel.java TEST_VM_OPTS="-XX:StartFlightRecording"
> - [x] TEST=hotspot_gc_shenandoah
> - [x] GHA

Xiaolong Peng has updated the pull request incrementally with one additional commit since the last revision:

  Keep gc id and shenandoah internal gc count in sync

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/24166/files
  - new: https://git.openjdk.org/jdk/pull/24166/files/4c8c8136..f4844848

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=24166&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=24166&range=03-04

  Stats: 9 lines in 4 files changed: 3 ins; 2 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/24166.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/24166/head:pull/24166

PR: https://git.openjdk.org/jdk/pull/24166


More information about the hotspot-gc-dev mailing list