mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
handle case of write pages being swapped out upon write release
This commit is contained in:
parent
831100a1f0
commit
04c7933c87
2 changed files with 29 additions and 16 deletions
|
|
@ -1182,7 +1182,7 @@ pub fn evict_page_inner(target_pid: PID, vaddr: usize) -> Result<usize, xous_ker
|
|||
// return us to the swapper PID -- this call can only originate in the swapper
|
||||
#[cfg(feature = "debug-swap")]
|
||||
{
|
||||
crate::arch::mem::MemoryMapping::current().print_map();
|
||||
// crate::arch::mem::MemoryMapping::current().print_map();
|
||||
println!(
|
||||
"evict_page_inner() failed sanity check. PTE: {:x?} paddr: {:x} vaddr in PID{}: {:x}",
|
||||
target_pte,
|
||||
|
|
|
|||
|
|
@ -870,21 +870,34 @@ impl Swap {
|
|||
let flash_vaddr = MMAP_VIRT_BASE + flash_offset;
|
||||
// evict_page_inner marks the page as swapped/invalid in src_pid, but also maps the page
|
||||
// into the swapper's address space
|
||||
let swap_vaddr = crate::arch::mem::evict_page_inner(src_pid, flash_vaddr).unwrap();
|
||||
|
||||
// release the page from the swapper's address space
|
||||
MemoryManager::with_mut(|mm| {
|
||||
let paddr = crate::arch::mem::virt_to_phys(swap_vaddr).unwrap() as usize;
|
||||
#[cfg(feature = "debug-swap-verbose")]
|
||||
println!("Release flash backing page - paddr {:x}", paddr);
|
||||
// this call unmaps the virtual page from the page table
|
||||
crate::arch::mem::unmap_page_inner(mm, swap_vaddr).expect("couldn't unmap page");
|
||||
// This call releases the physical page from the RPT - the pid has to match that of
|
||||
// the original owner. This is the "pointy end" of the stick;
|
||||
// after this call, the memory is now back into the free pool.
|
||||
mm.release_page_swap(paddr as *mut usize, src_pid)
|
||||
.expect("couldn't free page that was swapped out");
|
||||
});
|
||||
match crate::arch::mem::evict_page_inner(src_pid, flash_vaddr) {
|
||||
Ok(swap_vaddr) => {
|
||||
// release the page from the swapper's address space
|
||||
MemoryManager::with_mut(|mm| {
|
||||
let paddr = crate::arch::mem::virt_to_phys(swap_vaddr).unwrap() as usize;
|
||||
#[cfg(feature = "debug-swap-verbose")]
|
||||
println!("Release flash backing page - paddr {:x}", paddr);
|
||||
// this call unmaps the virtual page from the page table
|
||||
crate::arch::mem::unmap_page_inner(mm, swap_vaddr).expect("couldn't unmap page");
|
||||
// This call releases the physical page from the RPT - the pid has to match that
|
||||
// of the original owner. This is the "pointy end" of
|
||||
// the stick; after this call, the memory is now back
|
||||
// into the free pool.
|
||||
mm.release_page_swap(paddr as *mut usize, src_pid)
|
||||
.expect("couldn't free page that was swapped out");
|
||||
});
|
||||
}
|
||||
Err(xous_kernel::Error::BadAddress) => {
|
||||
#[cfg(feature = "debug-swap")]
|
||||
println!("Written page wasn't mapped {:x}", flash_vaddr);
|
||||
// in this case, it wasn't mapped into memory. We have been returned to the
|
||||
// swapper's memory space, and we can just move to
|
||||
// checking the next page
|
||||
}
|
||||
_ => {
|
||||
panic!("Unexpected error in WriteToFlash page free")
|
||||
}
|
||||
}
|
||||
|
||||
// Unhalt IRQs
|
||||
self.swap_restore_irq();
|
||||
|
|
|
|||
Loading…
Reference in a new issue