RFR: 8368089: G1: G1PeriodicGCTask::should_start_periodic_gc may use uninitialised value if os::loadavg is unsupported

Thomas Schatzl tschatzl at openjdk.org
Mon Sep 22 08:36:06 UTC 2025


On Sun, 21 Sep 2025 23:52:15 GMT, Guanqiang Han <ghan at openjdk.org> wrote:

> Please review this change. Thanks!
> 
> **Description:**
> 
> Previously the check combined loadavg() failure and threshold comparison in a single condition. When os::loadavg() returned -1, `recent_load` contained an undefined value but was still logged as if it was a real load average, leading to misleading log output.
> 
> **Fix:**
> 
> This change separates the failure case from the combined check:
> - If os::loadavg() returns -1, log "System loadavg not supported" and skip.
> - Only compare `recent_load` to the threshold when loadavg() succeeds.
> 
> **Test:**
> 
> GHA

src/hotspot/share/gc/g1/g1PeriodicGCTask.cpp line 61:

> 59:       log_debug(gc, periodic)("System loadavg not supported. Skipping.");
> 60:       return false;
> 61:     }

is `os::loadavg` support something that is fixed for a given run? It would maybe be nicer to fail the VM if `G1PeriodicGCSystemLoadThreshold` is set but `os::loadavg()` not supported. Or start with a warning and disable the functionality instead of printing the message over and over again.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27413#discussion_r2367119989


More information about the hotspot-gc-dev mailing list