Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Fix implementation of GCToOSInterface::VirtualCommit to ditch the pages - #4907

Merged
sergiy-k merged 1 commit into
dotnet:masterfrom
jkotas:virtualdecommit-fix
Nov 10, 2017
Merged

sergiy-k merged 1 commit into
dotnet:masterfrom
jkotas:virtualdecommit-fix

Conversation

@jkotas

@jkotas jkotas commented Nov 10, 2017

Copy link
Copy Markdown
Member

The GC depends on the pages to be zeroed out when they are mapped in again

The GC depends on the pages to be zeroed out when they are mapped in again
@jkotas jkotas mentioned this pull request Nov 10, 2017
@jkotas

jkotas commented Nov 10, 2017

Copy link
Copy Markdown
Member Author

@swgillespie I am also going to port it to CoreCLR copy of the GCToOSInterface once it is committed here.

// that much more clear to the operating system that we no
// longer need these pages. Also, GC depends on re-commited pages to
// be zeroed-out.
return mmap(address, size, PROT_NONE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0) != NULL;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware that you could overwrite existing mappings with mmap, so I did some reading and the language in macOS and Linux documentation seems to indicate that it'll remove any existing mappings that exist at the target location. Do you know if that means that if we e.g. decommit a subset of a full map (e.g. end of a segment), the kernel will toss out the entire mapping, or does it replace the mapping only at the target address + size leaving the rest of the mapping intact?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will replace the mapping only at the target address + size. This fix does exactly what we are doing in CoreCLR PAL today: https://github.com/dotnet/coreclr/blob/0ee3b5e64a98dc71aefed2304fe4bcf7f66ca9f5/src/pal/src/map/virtual.cpp#L1512

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to know! thanks!

@swgillespie swgillespie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, assuming that mmap does the expected thing 😄

@sergiy-k
sergiy-k merged commit f9bf1fc into dotnet:master Nov 10, 2017
@jkotas

jkotas commented Nov 10, 2017

Copy link
Copy Markdown
Member Author

@sergiy-k CI is down ... the PRs show as green, but no builds & tests run on them. Hopefully, this one won't break anything... .

@sergiy-k

Copy link
Copy Markdown
Contributor

Yeah, I noticed that after merging the change. Though I did test your change locally on a couple of machines.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants