From 4a9327f9a1af89b3d06a71906a4193ea90db19c0 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Tue, 31 Dec 2024 11:59:30 -0800 Subject: [PATCH] fix(hal-x86_64): remove tracing from PIT sleep (#499) The current code for sleeping using the PIT one-shot timer has a bunch of tracing in it. This adds overhead which makes the sleep duration way less accurate, making PIT calibration for the local APIC timer way sloppier. This commit removes the tracing. PIT calibration accuracy still sucks, but it sucks less now. --- hal-x86_64/src/time/pit.rs | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/hal-x86_64/src/time/pit.rs b/hal-x86_64/src/time/pit.rs index df2e5731..93e2f385 100644 --- a/hal-x86_64/src/time/pit.rs +++ b/hal-x86_64/src/time/pit.rs @@ -271,13 +271,13 @@ impl Pit { /// /// [`Controller::init`]: crate::interrupt::Controller::init /// [`interrupt`]: crate::interrupt - #[tracing::instrument( - name = "Pit::sleep_blocking" - level = tracing::Level::DEBUG, - skip(self), - fields(?duration), - err, - )] + // #[tracing::instrument( + // name = "Pit::sleep_blocking" + // level = tracing::Level::DEBUG, + // skip(self), + // fields(?duration), + // err, + // )] pub fn sleep_blocking(&mut self, duration: Duration) -> Result<(), PitError> { SLEEPING .compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire) @@ -291,11 +291,11 @@ impl Pit { cpu::wait_for_interrupt(); } - tracing::info!(?duration, "slept using PIT channel 0"); + // tracing::info!(?duration, "slept using PIT channel 0"); // if we were previously in periodic mode, re-enable it. if let Some(interval) = self.channel0_interval { - tracing::debug!("restarting PIT periodic timer"); + // tracing::debug!("restarting PIT periodic timer"); self.start_periodic_timer(interval)?; } @@ -366,13 +366,13 @@ impl Pit { /// This configures the PIT in mode 0 (oneshot mode). Once the interrupt has /// fired, in order to use the periodic timer, the pit must be put back into /// periodic mode by calling [`Pit::start_periodic_timer`]. - #[tracing::instrument( - name = "Pit::interrupt_in" - level = tracing::Level::DEBUG, - skip(self), - fields(?duration), - err, - )] + // #[tracing::instrument( + // name = "Pit::interrupt_in" + // level = tracing::Level::DEBUG, + // skip(self), + // fields(?duration), + // err, + // )] pub fn interrupt_in(&mut self, duration: Duration) -> Result<(), InvalidDuration> { let duration_ms = usize::try_from(duration.as_millis()).map_err(|_| { InvalidDuration::new( @@ -388,7 +388,7 @@ impl Pit { ) })?; - tracing::trace!(?duration, duration_ms, target_time, "Pit::interrupt_in"); + // tracing::trace!(?duration, duration_ms, target_time, "Pit::interrupt_in"); let command = Command::new() // use the binary counter @@ -410,19 +410,19 @@ impl Pit { } fn set_divisor(&mut self, divisor: u16) { - tracing::trace!(divisor = &fmt::hex(divisor), "Pit::set_divisor"); + // tracing::trace!(divisor = &fmt::hex(divisor), "Pit::set_divisor"); let low = divisor as u8; let high = (divisor >> 8) as u8; unsafe { self.channel0.writeb(low); // write the low byte - tracing::trace!(lo = &fmt::hex(low), "pit.channel0.writeb(lo)"); + // tracing::trace!(lo = &fmt::hex(low), "pit.channel0.writeb(lo)"); self.channel0.writeb(high); // write the high byte - tracing::trace!(hi = &fmt::hex(high), "pit.channel0.writeb(hi)"); + // tracing::trace!(hi = &fmt::hex(high), "pit.channel0.writeb(hi)"); } } fn send_command(&self, command: Command) { - tracing::debug!(?command, "Pit::send_command"); + // tracing::debug!(?command, "Pit::send_command"); unsafe { self.command.writeb(command.bits()); }