From c5aee478614a40fe752018c4746374fcaf3d8a39 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 19 Jun 2024 21:37:00 +0800 Subject: [PATCH] update comment to reflect current policy on OOM I think it's more Xous-y to punt to userland in the case that no consecutive memory is found, rather than trying to implement an evictor in the kernel itself. For now, the blunt hammer we use is to simply request some blocks be freed and we retry; this works well enough to find blocks of a few pages in sequence. If we needed larger blocks, we may want to consider modifying the swapper userland algorithm to have some API for finding consecutive runs of non-wired memory to swap out. --- kernel/src/mem.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/kernel/src/mem.rs b/kernel/src/mem.rs index e0e967f84..96b8b1f8a 100644 --- a/kernel/src/mem.rs +++ b/kernel/src/mem.rs @@ -640,15 +640,11 @@ impl MemoryManager { #[cfg(feature = "debug-swap")] println!("Block found starting at {:x}", phys); } else { - // See below comment about future enhancement to use swap to clear a memory range return Err(xous_kernel::Error::OutOfMemory); } } else { // couldn't find a contiguous location large enough; OOM for now. - // - // If swap memory is active, we could recode this case to search for the - // longest existing run, and try to extend it by evicting physical pages - // to swap. But let's keep it simple for now. + // Punt to userland to clear up memory. return Err(xous_kernel::Error::OutOfMemory); } }