Unconditionally enable sys_stat

This commit is contained in:
bjorn3
2025-10-25 18:52:07 +02:00
parent a57c8e410d
commit cc01d14d3b
4 changed files with 7 additions and 39 deletions
-2
View File
@@ -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"]
+1 -27
View File
@@ -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<usize> {
IRQ_COUNT
.iter()
+5 -6
View File
@@ -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()
+1 -4
View File
@@ -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.
/*