Support toggling profiling.
This commit is contained in:
@@ -3,6 +3,7 @@ use core::sync::atomic::Ordering;
|
||||
use x86::irq::PageFaultError;
|
||||
|
||||
use crate::memory::GenericPfFlags;
|
||||
use crate::scheme::serio::IS_PROFILING;
|
||||
use crate::{
|
||||
interrupt::stack_trace,
|
||||
paging::VirtualAddress,
|
||||
@@ -50,6 +51,9 @@ interrupt_stack!(non_maskable, @paranoid, |stack| {
|
||||
let Some(profiling) = crate::percpu::PercpuBlock::current().profiling else {
|
||||
return;
|
||||
};
|
||||
if !IS_PROFILING.load(Ordering::Relaxed) {
|
||||
return;
|
||||
}
|
||||
if stack.iret.cs & 0b00 == 0b11 {
|
||||
profiling.nmi_ucount.store(profiling.nmi_ucount.load(Ordering::Relaxed) + 1, Ordering::Relaxed);
|
||||
return;
|
||||
|
||||
+13
-1
@@ -1,7 +1,7 @@
|
||||
//! PS/2 unfortunately requires a kernel driver to prevent race conditions due
|
||||
//! to how status is utilized
|
||||
use core::str;
|
||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||
use core::sync::atomic::{AtomicUsize, Ordering, AtomicBool};
|
||||
|
||||
use spin::RwLock;
|
||||
|
||||
@@ -25,8 +25,20 @@ struct Handle {
|
||||
// Using BTreeMap as hashbrown doesn't have a const constructor.
|
||||
static HANDLES: RwLock<BTreeMap<usize, Handle>> = RwLock::new(BTreeMap::new());
|
||||
|
||||
pub const PROFILE_TOGGLEABLE: bool = true;
|
||||
pub static IS_PROFILING: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// Add to the input queue
|
||||
pub fn serio_input(index: usize, data: u8) {
|
||||
if PROFILE_TOGGLEABLE {
|
||||
if index == 0 && data == 30 {
|
||||
log::info!("Enabling profiling");
|
||||
IS_PROFILING.store(true, Ordering::SeqCst);
|
||||
} else if index == 0 && data == 48 {
|
||||
log::info!("Disabling profiling");
|
||||
IS_PROFILING.store(false, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
INPUT[index].send(data);
|
||||
|
||||
for (id, _handle) in HANDLES.read().iter() {
|
||||
|
||||
Reference in New Issue
Block a user