Skip to content

Commit

Permalink
Optimize VMM creation of reserved ranges by skipping the loop that
Browse files Browse the repository at this point in the history
attempts to map pages

Signed-off-by: Jon Lange <jlange@microsoft.com>
  • Loading branch information
msft-jlange committed Dec 11, 2023
1 parent c03e02a commit bb8b94f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/mm/vm/mapping/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ pub trait VirtualMapping: core::fmt::Debug {
/// Mapping size. Will always be a multiple of `VirtualMapping::page_size()`
fn mapping_size(&self) -> usize;

/// Indicates whether the mapping has any associated data.
///
/// # Returns
///
/// `true' if there is associated physical data, or `false' if there is
/// none.
fn has_data(&self) -> bool {
// Defaults to true
true
}

/// Request physical address to map for a given offset
///
/// # Arguments
Expand Down
4 changes: 4 additions & 0 deletions src/mm/vm/mapping/reserved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ impl VirtualMapping for VMReserved {
self.size
}

fn has_data(&self) -> bool {
false
}

fn map(&self, _offset: usize) -> Option<PhysAddr> {
None
}
Expand Down
5 changes: 5 additions & 0 deletions src/mm/vm/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ impl VMR {
let page_size = mapping.page_size();
let shared = mapping.shared();

// Exit early if the mapping has no data.
if !mapping.has_data() {
return Ok(());
}

while vmm_start + offset < vmm_end {
let idx = PageTable::index::<3>(VirtAddr::from(vmm_start - rstart));
if let Some(paddr) = mapping.map(offset) {
Expand Down

0 comments on commit bb8b94f

Please sign in to comment.