Integrated: 8372540: SerialGC: Remove race between allocation and expansion before is_init_completed

Axel Boldt-Christmas aboldtch at openjdk.org
Tue Dec 2 11:02:02 UTC 2025


On Mon, 1 Dec 2025 10:52:47 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

> JDK-8370943 added the ability to expand the heap for Serial and Parallel without having to GC during early startup (before `is_init_completed`). The expansion code was written with the assumption that it is performed in a safepoint. 
> 
> We have currently observed one crash related to the fact that top is updated before we setup the card table.  But we can also see that the synchronisation between expansion and allocation is not correct. 
> 
> I propose that we create a critical section for the early expansion and any early allocation. 
> 
> We might want to relax this critical section in the future, after we have fixed the expansion code and allocation interactions. But for now it seems safer to simply use a mutex.
> 
> _We also looked at using a RW style lock, but deemed it a bit unnecessary (https://github.com/openjdk/jdk/compare/master...xmas92:jdk:pre-init-expansion-rw-lock). Any potential performance gain may be better achieved by simply resolving the synchronisation issues with expansion._ 
> 
> * Testing
>   * GHA
>   * Tier 1-3 on Oracle supported platforms
>   * Stress-tested with reproducer `while java -XX:-UseCompressedOops -XX:+UseSerialGC -XX:InitialHeapSize=1m -Xmx1002M -version; do date;`

This pull request has now been integrated.

Changeset: e27abe8a
Author:    Axel Boldt-Christmas <aboldtch at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e27abe8a979880f308c69ea53319565dcd2142b6
Stats:     15 lines in 1 file changed: 8 ins; 0 del; 7 mod

8372540: SerialGC: Remove race between allocation and expansion before is_init_completed

Reviewed-by: ayang, sjohanss, eosterlund

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

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


More information about the hotspot-gc-dev mailing list