mmap/unix.rs: Add with_minimum_alignment to MmapRegionBuilder#375
mmap/unix.rs: Add with_minimum_alignment to MmapRegionBuilder#375jaredwhitedev wants to merge 2 commits into
mmap/unix.rs: Add with_minimum_alignment to MmapRegionBuilder#375Conversation
68f50c8 to
edb910a
Compare
edb910a to
c8904b3
Compare
|
Seems that we can't allocate with more than a 512 MiB alignment when using Miri. Would you rather we: |
|
|
||
| /// Create the `MmapRegion` object with the specified minimum alignment. | ||
| /// `min_align` must be a power of two and at least the system page size. | ||
| pub fn with_minimum_alignment(mut self, min_align: usize) -> Self { |
There was a problem hiding this comment.
Non-conformant values are rejected in the build function, but I think it will be better to reject them here. This function can return a Result<Self>. In the error case you return InvalidAlignment.
This is a cleaner approach. Users of the alignment value don't need to validate it again.
c8904b3 to
235023c
Compare
Add an option to specify a minimal alignment for the mmap'd region. This is useful to ensure VM memory backings get huge EPT entries. Signed-off-by: Jared White <git@jaredwhite.dev>
19deda4 to
a6229cb
Compare
Signed-off-by: Jared White <git@jaredwhite.dev>
a6229cb to
e42e47b
Compare
|
@jaredwhitedev are you still interested in getting this PR merged? If yes, could you please re-open it in https://github.com/rust-vmm/rust-vmm/. We moved vm-memory there. |
Add an option to specify a minimal alignment for the mmap'd region. This is useful to ensure VM memory backings get huge EPT entries.
Summary of the PR
Please summarize here why the changes in this PR are needed.
To get huge EPT entries callers must be able to align their memory to larger page sizes, such as 2 MiB or 1 GiB.
Using huge EPT entries increases the memory performance by decreasing the TLB pressure.
Expose a
with_minimum_alignmentoption toMmapRegionBuilderto allow callers to do so.To support this, we first allocate
size+alignment_sizeof virtual address space, then useMAP_FIXEDto place the actual mapping at an aligned address within the reserved VA space. We then free the excessRequirements
Before submitting your PR, please make sure you addressed the following
requirements:
git commit -s), and the commit message has max 60 characters for thesummary and max 75 characters for each description line.
test.
Release" section of CHANGELOG.md (if no such section exists, please create one).
unsafecode is properly documented.