mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
kernel: allow freeing unbacked virtual memory
Memory is on-demand allocated, meaning it's entirely possible to allocate and free memory without ever touching physical pages. Previously, when we attempted to free memory, it would skip over pages that were never backed by real memory. With this patch, we continue to free the virtual page even if there is no associated physical page. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
6304ba4616
commit
fa31e2235c
1 changed files with 8 additions and 2 deletions
|
|
@ -530,8 +530,14 @@ impl MemoryManager {
|
|||
/// * MemoryInUse - The specified page is already mapped
|
||||
pub fn unmap_page(&mut self, virt: *mut usize) -> Result<usize, xous_kernel::Error> {
|
||||
let pid = crate::arch::process::current_pid();
|
||||
let phys = crate::arch::mem::virt_to_phys(virt as usize)?;
|
||||
self.release_page(phys as *mut usize, pid)?;
|
||||
|
||||
// If the virtual address has an assigned physical address, release that
|
||||
// address from this process.
|
||||
if let Ok(phys) = crate::arch::mem::virt_to_phys(virt as usize) {
|
||||
self.release_page(phys as *mut usize, pid)?;
|
||||
};
|
||||
|
||||
// Free the virtual address.
|
||||
crate::arch::mem::unmap_page_inner(self, virt as usize)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue