RFR: 8328235: GenShen: Robustify ShenandoahGCSession and fix missing use [v10]
Y. Srinivas Ramakrishna
ysr at openjdk.org
Tue May 28 15:43:36 UTC 2024
> ShenandoahGCSession is intended to create a scope where the ShenandoahHeap's _gc_cause and _gc_generation field reflect the current gc cycle. We now check that we do not overwrite existing non-default settings (respectively _no_gc and nullptr). The destructor of the scope/stack object also resets these fields to their default settings, ensuring intended uses. This uncovered a situation where the scope was not entered when it should have been, which we have now fixed.
>
> A case of flickering of active_generation() was identified when used concurrently by mutators while it was being modified by the controller thread. To deal with this, we have carefully gone through the setting and use of the field, and found that an expedient fix for the race is to split the variable into two:
> - _gc_generation is set & cleared by the controller thread whenever it enters and exits a GC scope, and services concurrent gc cycles for young or old generations.
> - _active_generation is set to the value in _gc_generation at the start of each Shenandoah GC safepoint operation so that mutator threads and load barriers always see a consistent value between safepoints.
>
> Asserts check the protocol for setting and clearing the variables.
>
> An alternative approach is to not use a global variable for the _gc_generation indirected through the heap, but rather to pass it into the closures that do the work. This would work as well, but the changes would potentially touch more code. We would still have to have set the variable that is consulted by the load barriers, in a mutator-safe fashion at a safepoint, like we do today. This or other alternative approaches may be investigated in the future to potentially make this protocol more self-contained and robust rather than leaking as it does today into many places in the code.
>
> *Testing*:
> - [x] code pipeline
> - [x] specjbb testing
> - [ ] specjbb performance
> - [x] jtreg:hotspot_gc and jtreg:hotspot:tier1 w/fastdebug
> - [x] GHA
Y. Srinivas Ramakrishna has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 40 commits:
- Merge branch 'master' into active_generation
- Remove vestigial thread() method in ShenandoahController.
- cosmetic
- jcheck white-space
- Remove static _thread field introduced in ShenandoahController, as its
role is already served by the _control_thread field in ShenandoahHeap.
- Macro-ize previously inlined shenandoah assert.
- shenandoah_assert_generations_reconciled() macro instead of a method in
ShenandoahHeap, bringing it in line with shenandoah assertion check
idiom.
- Small clean-ups.
- jcheck whitespace
- Fixed mismerge because of code moving between files in merge from
master; encapsulate assert & provide more useful debugging info. We
aren't done yet... It might be the case that we do away with the
sync/async split of the variable and instead move the relevant state
into the closure if possible. That might have to wait for another day
though based on whether it'll work well everywhere or not.
- ... and 30 more: https://git.openjdk.org/shenandoah/compare/894aefc0...f1f40981
-------------
Changes: https://git.openjdk.org/shenandoah/pull/407/files
Webrev: https://webrevs.openjdk.org/?repo=shenandoah&pr=407&range=09
Stats: 167 lines in 17 files changed: 132 ins; 1 del; 34 mod
Patch: https://git.openjdk.org/shenandoah/pull/407.diff
Fetch: git fetch https://git.openjdk.org/shenandoah.git pull/407/head:pull/407
PR: https://git.openjdk.org/shenandoah/pull/407
More information about the shenandoah-dev
mailing list