Skip to content

Commit

Permalink
Merge pull request #179 from msft-jlange/mapopt
Browse files Browse the repository at this point in the history
Optimize VMM creation of reserved ranges
  • Loading branch information
joergroedel authored Dec 14, 2023
2 parents be3309d + bb8b94f commit 7957207
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 7957207

Please sign in to comment.