diff --git a/Cargo.toml b/Cargo.toml index a3b4d7b7a7..c71d8bc269 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,6 @@ default = [ "multi_core", "serial_debug", "self_modifying", - "sys_stat", "x86_kvm_pv", #"syscall_debug" ] @@ -67,7 +66,6 @@ pti = [] qemu_debug = [] serial_debug = [] system76_ec_debug = [] -sys_stat = [] x86_kvm_pv = [] debugger = ["syscall_debug"] diff --git a/src/cpu_stats.rs b/src/cpu_stats.rs index afe10887a3..7a23db0d11 100644 --- a/src/cpu_stats.rs +++ b/src/cpu_stats.rs @@ -1,9 +1,6 @@ +use alloc::{string::String, vec::Vec}; use core::sync::atomic::{AtomicU8, AtomicUsize, Ordering}; -use alloc::string::String; -#[cfg(feature = "sys_stat")] -use alloc::vec::Vec; - use crate::cpu_set::LogicalCpuId; // Note: Using AtomicUsize rather than AtomicU64 as 32bit x86 doesn't support the latter @@ -77,10 +74,6 @@ impl CpuStats { /// * `new_state` - The state of the CPU for the following ticks. #[inline] pub fn set_state(&self, new_state: CpuState) { - if cfg!(not(feature = "sys_stat")) { - return; - } - self.state.store(new_state as u8, Ordering::Relaxed); } @@ -92,10 +85,6 @@ impl CpuStats { /// * `ticks` - NUmber of ticks to add. #[inline] pub fn add_time(&self, ticks: usize) { - if cfg!(not(feature = "sys_stat")) { - return; - } - match self.state.load(Ordering::Relaxed) { val if val == CpuState::Idle as u8 => self.idle.fetch_add(ticks, Ordering::Relaxed), val if val == CpuState::User as u8 => self.user.fetch_add(ticks, Ordering::Relaxed), @@ -113,10 +102,6 @@ impl CpuStats { /// * `irq` - The ID of the interrupt that happened. #[inline] pub fn add_irq(&self, irq: u8) { - if cfg!(not(feature = "sys_stat")) { - return; - } - IRQ_COUNT[irq as usize].fetch_add(1, Ordering::Relaxed); self.irq.fetch_add(1, Ordering::Relaxed); } @@ -151,15 +136,10 @@ impl From<&CpuStats> for CpuStatsData { /// Add a context switch to the count. #[inline] pub fn add_context_switch() { - if cfg!(not(feature = "sys_stat")) { - return; - } - CONTEXT_SWITCH_COUNT.fetch_add(1, Ordering::Relaxed); } /// Get the number of context switches. -#[cfg(feature = "sys_stat")] pub fn get_context_switch_count() -> usize { CONTEXT_SWITCH_COUNT.load(Ordering::Relaxed) } @@ -167,21 +147,15 @@ pub fn get_context_switch_count() -> usize { /// Add a context creation to the count. #[inline] pub fn add_context() { - if cfg!(not(feature = "sys_stat")) { - return; - } - CONTEXTS_COUNT.fetch_add(1, Ordering::Relaxed); } /// Get the number of contexts created. -#[cfg(feature = "sys_stat")] pub fn get_contexts_count() -> usize { CONTEXTS_COUNT.load(Ordering::Relaxed) } /// Get the count of each interrupt. -#[cfg(feature = "sys_stat")] pub fn irq_counts() -> Vec { IRQ_COUNT .iter() diff --git a/src/percpu.rs b/src/percpu.rs index d86cbb4345..02c187c6fc 100644 --- a/src/percpu.rs +++ b/src/percpu.rs @@ -1,9 +1,12 @@ +use alloc::{ + sync::{Arc, Weak}, + vec::Vec, +}; use core::{ cell::{Cell, RefCell}, sync::atomic::{AtomicBool, AtomicPtr, Ordering}, }; -use alloc::sync::{Arc, Weak}; use rmm::Arch; use syscall::PtraceFlags; @@ -11,14 +14,11 @@ use crate::{ arch::device::ArchPercpuMisc, context::{empty_cr3, memory::AddrSpaceWrapper, switch::ContextSwitchPercpu}, cpu_set::{LogicalCpuId, MAX_CPU_COUNT}, - cpu_stats::CpuStats, + cpu_stats::{CpuStats, CpuStatsData}, ptrace::Session, syscall::debug::SyscallDebugInfo, }; -#[cfg(feature = "sys_stat")] -use {crate::cpu_stats::CpuStatsData, alloc::vec::Vec}; - /// The percpu block, that stored all percpu variables. pub struct PercpuBlock { /// A unique immutable number that identifies the current CPU - used for scheduling @@ -55,7 +55,6 @@ pub unsafe fn init_tlb_shootdown(id: LogicalCpuId, block: *mut PercpuBlock) { ALL_PERCPU_BLOCKS[id.get() as usize].store(block, Ordering::Release) } -#[cfg(feature = "sys_stat")] pub fn get_all_stats() -> Vec<(LogicalCpuId, CpuStatsData)> { let mut res = ALL_PERCPU_BLOCKS .iter() diff --git a/src/scheme/sys/mod.rs b/src/scheme/sys/mod.rs index 49262ca6f2..fa7a6ef714 100644 --- a/src/scheme/sys/mod.rs +++ b/src/scheme/sys/mod.rs @@ -42,12 +42,10 @@ mod irq; mod log; mod scheme; mod scheme_num; +mod stat; mod syscall; mod uname; -#[cfg(feature = "sys_stat")] -mod stat; - enum Handle { TopLevel, Resource { @@ -85,7 +83,6 @@ const FILES: &[(&str, Kind)] = &[ ("env", Rd(|_| Ok(Vec::from(crate::init_env())))), #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] ("spurious_irq", Rd(interrupt::irq::spurious_irq_resource)), - #[cfg(feature = "sys_stat")] ("stat", Rd(stat::resource)), // Disabled because the debugger is inherently unsafe and probably will break the system. /*