From e58cdd151e0dd98f8829e398162907ee512d4a7a 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 | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/hal-x86_64/src/time/pit.rs b/hal-x86_64/src/time/pit.rs index df2e5731..6ecaf3a9 100644 --- a/hal-x86_64/src/time/pit.rs +++ b/hal-x86_64/src/time/pit.rs @@ -271,19 +271,14 @@ 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, - )] pub fn sleep_blocking(&mut self, duration: Duration) -> Result<(), PitError> { SLEEPING .compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire) .map_err(|_| PitError::SleepInProgress)?; self.interrupt_in(duration) .map_err(PitError::InvalidDuration)?; + + // Tracing here is fine, because we are already sleeping... tracing::debug!("started PIT sleep"); // spin until the sleep interrupt fires. @@ -291,11 +286,8 @@ impl Pit { cpu::wait_for_interrupt(); } - 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"); self.start_periodic_timer(interval)?; } @@ -366,13 +358,6 @@ 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, - )] pub fn interrupt_in(&mut self, duration: Duration) -> Result<(), InvalidDuration> { let duration_ms = usize::try_from(duration.as_millis()).map_err(|_| { InvalidDuration::new( @@ -388,8 +373,6 @@ impl Pit { ) })?; - tracing::trace!(?duration, duration_ms, target_time, "Pit::interrupt_in"); - let command = Command::new() // use the binary counter .with(Command::BCD_BINARY, false) @@ -410,19 +393,16 @@ impl Pit { } fn set_divisor(&mut self, divisor: u16) { - 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)"); self.channel0.writeb(high); // write the high byte - 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()); }