-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
demand paging for anonymous mmaps #607
Merged
Merged
Conversation
This file contains 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
…lidate into interrupt.c
Closed
Closed
mkhon
reviewed
Mar 19, 2019
src/unix/mmap.c
Outdated
// its really unclear whether this should be extended or truncated | ||
u64 len = pad(size, PAGESIZE) & MASK(32); | ||
u64 where = u64_from_pointer(target); | ||
u64 end = where + size - 1; | ||
boolean fixed = (flags & MAP_FIXED) != 0; | ||
thread_log(current, "mmap: target %p, size %P, prot %P, flags %P, fd %d, offset %P", | ||
boolean mapped = false; | ||
thread_log(current, "mmap: target %p, size %P, prot %P, flags %P, fd %d, offset %P\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thread_log() appends "\n" historically. This should probably be fixed there.
mkhon
approved these changes
Mar 19, 2019
Closed
Closed
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.
This introduces demand paging for non-backed mmaps. The need for this has been exposed by ruby with sinatra which has been doing a number of large anonymous mmaps with each web request (though most are immediately unmapped). In general, we're seeing programs assume that the host OS environment does demand paging and that large anonymous mmaps are inexpensive. So we're following suit by adding a primitive page fault handler to map and zero 4K pages.
There's more work to do on the munmap(2) side, but this will at least allow the ruby/sinatra demo to run with somewhat acceptable performance. Previously, maps and unmaps of several hundred MB would occur several times in succession, leading to extremely slow response (this was with the munmap branch - it wouldn't even run without it). Here, munmap(2) is removed (there's some deeper plumbing that needs to happen to do it right), but the test will at least honor ~100 requests before falling over from exhausting the page tables. That issue will be addressed with the munmap(2) implementation.
Note that a bit of reworking of the context/frame saving was necessary here, and also that there is an alternate stack for the page fault handler (only vector 14; the others remain on the existing stack) so that faults on stack pages may be correctly handled. This is possible thanks to the IST vectors in the long mode TSS.
This could use a runtime test...ideas welcome.
related: #586, #562, #526