From bfef60a0b1c00123783b654eeed20b24b8d79b3b Mon Sep 17 00:00:00 2001 From: bunnie Date: Tue, 21 May 2024 18:38:37 +0800 Subject: [PATCH] add a configuration that works for some reason a debug-print is essential for the system to run stably. It smells like we're violating some minimum time between accesses of SPIM interface, or else we're encoutnering some weird optimization bug. --- services/xous-swapper/Cargo.toml | 2 +- services/xous-swapper/src/main.rs | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/services/xous-swapper/Cargo.toml b/services/xous-swapper/Cargo.toml index ecc9e85cf..ea015815b 100644 --- a/services/xous-swapper/Cargo.toml +++ b/services/xous-swapper/Cargo.toml @@ -38,4 +38,4 @@ swap-userspace-testing = [] debug-print = [] debug-verbose = [] -default = ["debug-print", "debug-verbose"] +default = ["debug-print"] diff --git a/services/xous-swapper/src/main.rs b/services/xous-swapper/src/main.rs index f823b1fde..1dbc190be 100644 --- a/services/xous-swapper/src/main.rs +++ b/services/xous-swapper/src/main.rs @@ -460,7 +460,7 @@ fn swap_handler( let ss = sss.inner.as_mut().expect("Shared state should be initialized"); let op: Option = FromPrimitive::from_usize(opcode); - #[cfg(feature = "debug-print")] + #[cfg(feature = "debug-print-verbose")] writeln!(DebugUart {}, "got Opcode: {:?}", op).ok(); match op { Some(KernelOp::WriteToSwap) => { @@ -483,15 +483,6 @@ fn swap_handler( let pid = a2 as u8; let vaddr_in_pid = a3; let vaddr_in_swap = a4; - #[cfg(feature = "debug-print")] - writeln!( - DebugUart {}, - "RFS PID{}, vaddr_pid {:x}, vaddr_swap {:x}", - pid, - vaddr_in_pid, - vaddr_in_swap - ) - .ok(); // walk the PT to find the swap data, and remove it from the swap PT let paddr_in_swap = match ss.pt_walk(pid as u8, vaddr_in_pid, true) { Some(paddr) => paddr, @@ -501,8 +492,19 @@ fn swap_handler( panic!("Couldn't resolve swapped data. Was the page actually swapped?") } }; - #[cfg(feature = "debug-verbose")] - writeln!(DebugUart {}, " resolved paddr_in_swap {:x}", paddr_in_swap).ok(); + // for some reason, `paddr_in_swap` must be printed for the routine to not crash. Or the delay + // after `pt_walk` is necessary. Either way, it's spooky. I wonder if there isn't some minimum + // time between reads from the SPIM that we're violating?? + #[cfg(feature = "debug-print")] + writeln!( + DebugUart {}, + "RFS PID{}, vaddr_pid {:x}, vaddr_swap {:x}, paddr {:x}", + pid, + vaddr_in_pid, + vaddr_in_swap, + paddr_in_swap + ) + .ok(); // clear the used bit in swap ss.sct.counts[paddr_in_swap / PAGE_SIZE] &= !loader::FLG_SWAP_USED;