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

Stefan Johansson sjohanss at openjdk.org
Mon Dec 1 14:43:33 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

Marked as reviewed by sjohanss (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/28573#pullrequestreview-3525342381


More information about the hotspot-gc-dev mailing list