Repository navigation
Fix implementation of GCToOSInterface::VirtualCommit to ditch the pages - #4907
Conversation
The GC depends on the pages to be zeroed out when they are mapped in again
|
@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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
swgillespie
left a comment
There was a problem hiding this comment.
looks good to me, assuming that mmap does the expected thing 😄
|
@sergiy-k CI is down ... the PRs show as green, but no builds & tests run on them. Hopefully, this one won't break anything... . |
|
Yeah, I noticed that after merging the change. Though I did test your change locally on a couple of machines. |
The GC depends on the pages to be zeroed out when they are mapped in again