From 1b3e024f7d1ea1b33def52905871fdd3aafa24d5 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sat, 23 Mar 2024 15:52:18 +0100 Subject: [PATCH] Fix profiling code. --- src/arch/x86_shared/idt.rs | 2 +- src/profiling.rs | 6 ++++-- src/scheme/debug.rs | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/arch/x86_shared/idt.rs b/src/arch/x86_shared/idt.rs index 7c349093cb..603b198213 100644 --- a/src/arch/x86_shared/idt.rs +++ b/src/arch/x86_shared/idt.rs @@ -25,7 +25,7 @@ pub type IdtReservations = [AtomicU32; 8]; #[repr(C)] pub struct Idt { - entries: IdtEntries, + pub(crate) entries: IdtEntries, reservations: IdtReservations, } impl Idt { diff --git a/src/profiling.rs b/src/profiling.rs index 83b3d64f4a..fa7c9de4fe 100644 --- a/src/profiling.rs +++ b/src/profiling.rs @@ -12,7 +12,7 @@ use crate::{ interrupt::{irq::aux_timer, InterruptStack}, percpu::PercpuBlock, syscall::{error::*, usercopy::UserSliceWo}, - LogicalCpuId, + cpu_set::LogicalCpuId, }; const N: usize = 64 * 1024 * 1024; @@ -96,14 +96,16 @@ const NULL: AtomicPtr = AtomicPtr::new(core::ptr::null_mut()); pub static BUFS: [AtomicPtr; 4] = [NULL; 4]; pub const PROFILE_TOGGLEABLE: bool = true; -pub static IS_PROFILING: AtomicBool = AtomicBool::new(false); +pub static IS_PROFILING: AtomicBool = AtomicBool::new(true); pub fn serio_command(index: usize, data: u8) { if PROFILE_TOGGLEABLE { if index == 0 && data == 30 { + // "a" key in QEMU log::info!("Enabling profiling"); IS_PROFILING.store(true, Ordering::SeqCst); } else if index == 0 && data == 48 { + // "b" key log::info!("Disabling profiling"); IS_PROFILING.store(false, Ordering::SeqCst); } diff --git a/src/scheme/debug.rs b/src/scheme/debug.rs index 29ed755db9..ac1ce6703b 100644 --- a/src/scheme/debug.rs +++ b/src/scheme/debug.rs @@ -121,7 +121,7 @@ impl KernelScheme for DebugScheme { #[cfg(feature = "profiling")] if handle.num != !0 { return crate::profiling::drain_buffer( - crate::LogicalCpuId::new(handle.num as u32), + crate::cpu_set::LogicalCpuId::new(handle.num as u32), buf, ); }