diff --git a/src/rt.rs b/src/rt.rs index 7ad402fd..733f7f88 100644 --- a/src/rt.rs +++ b/src/rt.rs @@ -9,7 +9,7 @@ use maitake::{ scheduler::{self, StaticScheduler, Stealer}, time, }; -use mycelium_util::sync::InitOnce; +use mycelium_util::{fmt, sync::InitOnce}; use rand::Rng; pub use maitake::task::JoinHandle; @@ -95,6 +95,13 @@ pub fn init() { tracing::info!("kernel runtime initialized"); } +pub const DUMP_RT: crate::shell::Command = crate::shell::Command::new("rt") + .with_help("print the kernel's async runtime") + .with_fn(|_| { + tracing::info!(runtime = ?RUNTIME); + Ok(()) + }); + static SCHEDULER: arch::LocalKey>> = arch::LocalKey::new(|| Cell::new(None)); @@ -281,3 +288,14 @@ impl Runtime { self.cores[idx].try_get()?.try_steal().ok() } } + +impl fmt::Debug for Runtime { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let cores = self.active_cores(); + f.debug_struct("Runtime") + .field("active_cores", &cores) + .field("cores", &&self.cores[..cores]) + .field("injector", &self.injector) + .finish() + } +} diff --git a/src/shell.rs b/src/shell.rs index 968695d0..700eea1a 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -46,6 +46,7 @@ pub fn eval(line: &str) { tracing::info!(timer = ?crate::rt::TIMER); Ok(()) }), + crate::rt::DUMP_RT, crate::arch::shell::DUMP_ARCH, Command::new("heap") .with_help("print kernel heap statistics")