mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
add ability to "touch" an alloc so that the LRU count updates
also add some debug access functions
This commit is contained in:
parent
3112f41d96
commit
19128a83a3
1 changed files with 26 additions and 0 deletions
|
|
@ -317,6 +317,30 @@ impl MemoryManager {
|
||||||
Err(xous_kernel::Error::OutOfMemory)
|
Err(xous_kernel::Error::OutOfMemory)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(baremetal)]
|
||||||
|
#[cfg(feature = "swap")]
|
||||||
|
// Take a physical address and indicate that it's been queried so it doesn't get suggested as LRU any time
|
||||||
|
// soon. Addresses outside of RAM are just ignored.
|
||||||
|
pub fn touch(&self, paddr: usize) {
|
||||||
|
if paddr >= self.ram_start && paddr < self.ram_start + self.ram_size {
|
||||||
|
unsafe {
|
||||||
|
MEMORY_ALLOCATIONS[(paddr - self.ram_start) / PAGE_SIZE].touch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "debug-swap")]
|
||||||
|
/// This function is "improper" in that it returns a bogus value if the memory allocations are
|
||||||
|
/// out of range, but its purpose is only for debugging. This is not suitable for use in any
|
||||||
|
/// other context.
|
||||||
|
pub unsafe fn get_timestamp(&self, paddr: usize) -> u32 {
|
||||||
|
if paddr >= self.ram_start && paddr < self.ram_start + self.ram_size {
|
||||||
|
unsafe { MEMORY_ALLOCATIONS[(paddr - self.ram_start) / PAGE_SIZE].get_timestamp() }
|
||||||
|
} else {
|
||||||
|
0xDEAD_BEEF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
#[cfg(feature = "swap")]
|
#[cfg(feature = "swap")]
|
||||||
/// Similar to alloc_page(), but this implementation can only be called in one location because
|
/// Similar to alloc_page(), but this implementation can only be called in one location because
|
||||||
|
|
@ -473,6 +497,8 @@ impl MemoryManager {
|
||||||
#[cfg(not(feature = "swap"))]
|
#[cfg(not(feature = "swap"))]
|
||||||
let phys = self.alloc_page(pid)?;
|
let phys = self.alloc_page(pid)?;
|
||||||
#[cfg(feature = "swap")]
|
#[cfg(feature = "swap")]
|
||||||
|
// this should not be OOMable because the callers for map_zeroed page are exclusively from kernel
|
||||||
|
// services (process creation, queue creation)
|
||||||
let phys = self.alloc_page(pid, Some(virt))?;
|
let phys = self.alloc_page(pid, Some(virt))?;
|
||||||
|
|
||||||
// Actually perform the map. At this stage, every physical page should be owned by us.
|
// Actually perform the map. At this stage, every physical page should be owned by us.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue