Fix GC page size assumptions - #134059
Open
kkokosa wants to merge 1 commit into
Open
Fix GC page size assumptions#134059kkokosa wants to merge 1 commit into
kkokosa wants to merge 1 commit into
Conversation
Ensure region mark bitmaps are independently page aligned and use the platform initial commit size when reclaiming regions before OOM. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @anicka-net, @dotnet/gc |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Existing ARM64 configurations may fail with 64-KiB pages, and the sizing comment remains inaccurate.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes GC region sizing and commitment accounting on systems with OS pages larger than 4 KiB.
Changes:
- Enforces a page-size-aware minimum GC region size.
- Uses
SEGMENT_INITIAL_COMMITfor pre-OOM reclamation. - Adds regression coverage and updates GC error resources.
File summaries
| File | Summary |
|---|---|
src/tests/GC/Regressions/Github/Runtime_133743/Runtime_133743.csproj |
Configures the regression test. |
src/tests/GC/Regressions/Github/Runtime_133743/Runtime_133743.cs |
Adds background-GC regression coverage. |
src/coreclr/pal/prebuilt/corerror/mscorurt.rc |
Updates the corresponding error resource. |
src/coreclr/inc/corerror.xml |
Updates GC region-size error text. |
src/coreclr/gc/regions_segments.cpp |
Corrects initial-commit comparison. |
src/coreclr/gc/interface.cpp |
Validates minimum region size. Moderate issue (3 votes): existing ARM64 configurations may fail on 64-KiB-page systems; nit (1 vote): the sizing comment no longer matches behavior. |
src/coreclr/gc/gcpriv.h |
Documents logical GC page granularity. |
Review details
Suppressed comments (1)
src/coreclr/gc/interface.cpp:451
- This revised comment still says automatic sizing chooses only 4, 2, or 1 MiB, but the
maxbelow can now select the platform-dependent minimum (8 MiB on 64-KiB pages). Please document the base-size selection and the subsequent minimum-size adjustment so the comment matches the new behavior.
// except for the smallest case.
- Files reviewed: 7/7 changed files
- Comments generated: 1
- Review effort level: Lite
Comment on lines
+472
to
+476
| else if (gc_region_size < min_gc_region_size) | ||
| { | ||
| log_init_error_to_host ("The GC RegionSize config is set to %zd bytes, it needs to be >= %zd bytes for the OS page size", | ||
| gc_region_size, min_gc_region_size); | ||
| return CLR_E_GC_BAD_REGION_SIZE; |
Member
Author
There was a problem hiding this comment.
Should we use something like this, fe. for Runtime_126043, to exclude those tests on non-4 KiB machines?
<CLRTestBashPreCommands><![CDATA[
$(CLRTestBashPreCommands)
page_size=`getconf PAGESIZE`
if [ "$page_size" -gt 32768 ]; then
echo "Test requires 4 MiB GC regions, which are unsupported with ${page_size}-byte OS pages."
exit 0
fi
export DOTNET_gcServer=1
export DOTNET_GCHeapCount=1
export DOTNET_GCRegionSize=400000
]]></CLRTestBashPreCommands>
Member
|
cc @tmds |
This was referenced Sep 16, 2026
janvorli
reviewed
Sep 17, 2026
| <Message>"GC Region Size must be less than 2GB."</Message> | ||
| <Comment>During a GC initialization, GC Region Size must be less than 2GB.</Comment> | ||
| <Message>"GC Region Size configuration is invalid."</Message> | ||
| <Comment>During a GC initialization, the GC Region Size configuration is invalid.</Comment> |
Member
There was a problem hiding this comment.
I would rather say:
Suggested change
| <Comment>During a GC initialization, the GC Region Size configuration is invalid.</Comment> | |
| <Comment>During a GC initialization, the GC Region Size configuration must be valid.</Comment> |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #133743.
On systems with OS pages larger than 4 KiB, GC regions could have mark bitmaps smaller than one OS page, causing regions to share committed bitmap pages and corrupt commitment accounting. The pre-OOM path also compared region commitment against the logical 4 KiB
GC_PAGE_SIZEinstead of the platform initial commit size.This change:
OS_PAGE_SIZEand mark-word coverageSEGMENT_INITIAL_COMMITfor pre-OOM reclamationValidated on ARM64 Linux with both 64 KiB and 4 KiB kernels. The regression fails before and passes after the fix on 64 KiB pages, while regular 4 KiB region sizing remains unchanged.