RFR: 8371381: [Shenandoah] Setting ergo flags should use FLAG_SET_ERGO

William Kemper wkemper at openjdk.org
Tue Nov 11 23:09:02 UTC 2025


On Tue, 11 Nov 2025 18:24:25 GMT, Rui Li <duke at openjdk.org> wrote:

> Setting ergo flags using `FLAG_SET_ERGO`, instead of `FLAG_SET_DEFAULT`, so we can have the right origin info.
> 
> Had to expand `ShenandoahEvacReserve` range from `range(1,100)` to `range(0,100)` because when we use shenandoah passive mode and degen is also turned off (`-XX:ShenandoahGCMode=passive -XX:-ShenandoahDegeneratedGC`), we set the ShenandoahEvacReserve to 0:  https://github.com/openjdk/jdk/blob/c6a8027b94bbcbde5f7dcabd0bff48b93bbb5a7f/src/hotspot/share/gc/shenandoah/mode/shenandoahPassiveMode.cpp#L41 The issue is surfaced now because `FLAG_SET_DEFAULT` doesn't check the range but `FLAG_SET_ERGO` does.
> 
> Testing: jtreg gc. GHA pending.

Changes requested by wkemper (Reviewer).

Hmm, setting `ShenandoahEvacReserve` to zero will cause a divide by zero error in other modes (it will even cause a divide by zero error in the passive mode if `ShenandoahDegeneratedGC` is enabled). I'd rather contain the accommodation for this configuration to the passive mode, than accept values that will cause crashes. Could we "inline" the macro on line 41 and allow zero only for this special configuration (passive mode and only full gcs) by changing the "inlined" macro to use `SET_DEFAULT` still?

src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp line 356:

> 354:           "regions) is also bounded by this parameter.  In percents of "    \
> 355:           "total (young-generation) heap size.")                            \
> 356:           range(0,100)                                                      \

If we allow this, somebody _will_ file a bug because `-XX:ShenandoahEvacReserve=0` will cause other modes to crash with divide by zero error.

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

PR Review: https://git.openjdk.org/jdk/pull/28242#pullrequestreview-3450500792
PR Comment: https://git.openjdk.org/jdk/pull/28242#issuecomment-3519062971
PR Review Comment: https://git.openjdk.org/jdk/pull/28242#discussion_r2516100105


More information about the hotspot-gc-dev mailing list