Skip to content

8280087: G1: Handle out-of-mark stack situations during reference processing more gracefully#4261

Open
zangcq wants to merge 4 commits intoopenjdk:masterfrom
zangcq:backport-8280087
Open

8280087: G1: Handle out-of-mark stack situations during reference processing more gracefully#4261
zangcq wants to merge 4 commits intoopenjdk:masterfrom
zangcq:backport-8280087

Conversation

@zangcq
Copy link

@zangcq zangcq commented Feb 6, 2026

I want backport JDK-8280087 to fix g1 markstack not expand problem. but this patch depend JDK-8307806 , so I want port this two patch together


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8280087 needs maintainer approval

Issue

  • JDK-8280087: G1: Handle out-of-mark stack situations during reference processing more gracefully (Enhancement - P3)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk17u-dev.git pull/4261/head:pull/4261
$ git checkout pull/4261

Update a local copy of the PR:
$ git checkout pull/4261
$ git pull https://git.openjdk.org/jdk17u-dev.git pull/4261/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4261

View PR using the GUI difftool:
$ git pr show -t 4261

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk17u-dev/pull/4261.diff

Using Webrev

Link to Webrev Comment

This change backports the dependency fix from OpenJDK commit f09a0f5ca787e139f240a33bb12491792b8e7003
to rename Atomic::fetch_and_add to Atomic::fetch_then_add across the codebase.

This is a prerequisite dependency for the G1 mark stack overflow fix (8280087).
The renaming provides better semantic clarity for atomic operations:
- fetch_then_add: atomically adds value and returns the old value
- add_then_fetch: atomically adds value and returns the new value

Key changes:
- Renamed all occurrences of fetch_and_add to fetch_then_add in 36 files
- Updated function declarations and implementations in atomic.hpp
- Updated platform-specific atomic implementations
- Updated all callers in GC subsystems (G1, Parallel, Shenandoah, ZGC)
- Updated test cases to use the new naming convention

This change maintains full backward compatibility and does not affect
the functionality of atomic operations, only their naming.

Reviewed-by: stefank, dholmes
Original-commit: f09a0f5ca787e139f240a33bb12491792b8e7003
…cessing more gracefully

This change backports the fix from OpenJDK commit f696796e888d62535e6c864ce6fdf912eef0c3ed
to improve G1's handling of mark stack overflow situations during reference processing.

Key changes:
- Refactored G1CMMarkStack to use a new ChunkAllocator class
- Implemented growable array data structure for better memory management
- Added set_should_grow() mechanism to prefer stack expansion during reference processing
- Removed old resize-based approach in favor of dynamic chunk allocation
- Added TestMarkStackOverflow.java test case

The fix allows the G1 mark stack to grow more gracefully during reference processing
phases, reducing the likelihood of overflow conditions that could cause marking
restarts or VM exits.

Reviewed-by: tschatzl, ayang
Original-commit: f696796e888d62535e6c864ce6fdf912eef0c3ed
@bridgekeeper
Copy link

bridgekeeper bot commented Feb 6, 2026

👋 Welcome back zangcq! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 6, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title Backport 8280087 8280087: G1: Handle out-of-mark stack situations during reference processing more gracefully Feb 6, 2026
@openjdk
Copy link

openjdk bot commented Feb 6, 2026

This backport pull request has now been updated with the original issue, but not the original commit. If you have the original commit hash, please update the pull request title with Backport <hash>.

@openjdk openjdk bot added the backport Port of a pull request already in a different code base label Feb 6, 2026
@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 6, 2026
@mlbridge
Copy link

mlbridge bot commented Feb 6, 2026

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Port of a pull request already in a different code base rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

1 participant