memfd: Reduce some syscalls in the on-demand case #3757
Merged
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 tweaks the internal organization of the
MemFdSlot
to avoid somesyscalls in the default case as well as opportunistically in the pooling
case. The two cases added here are:
A
MemFdSlot
is now created with a specified initial size. Forpooling this is 0 but for the on-demand case this can be non-zero.
When
instantiate
is called with no prior image and the sizes match(as will be the case for on-demand allocation) then
mprotect
isskipped entirely.
In the
clear_and_remain-ready
case themprotect
is skipped if theheap wasn't grown at all.
This should avoid ever using
mprotect
unnecessarily and makes theranges we
mprotect
a bit smaller as well.