From 0a314b0bad98b800c0f8ccaf2b028f315fb38d97 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sat, 30 Aug 2025 18:34:25 +0200 Subject: [PATCH] nvmed: Use std::hint::spin_loop --- storage/nvmed/src/main.rs | 3 --- storage/nvmed/src/nvme/mod.rs | 28 ++-------------------------- storage/nvmed/src/nvme/queues.rs | 2 +- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/storage/nvmed/src/main.rs b/storage/nvmed/src/main.rs index 342caf055e..9f328a78c4 100644 --- a/storage/nvmed/src/main.rs +++ b/storage/nvmed/src/main.rs @@ -1,6 +1,3 @@ -#![cfg_attr(target_arch = "aarch64", feature(stdarch_arm_hints))] // Required for yield instruction -#![cfg_attr(target_arch = "riscv64", feature(riscv_ext_intrinsics))] // Required for pause instruction - use std::cell::RefCell; use std::fs::File; use std::io::{self, Read, Write}; diff --git a/storage/nvmed/src/nvme/mod.rs b/storage/nvmed/src/nvme/mod.rs index 93dfab4ed2..312a0eb3e8 100644 --- a/storage/nvmed/src/nvme/mod.rs +++ b/storage/nvmed/src/nvme/mod.rs @@ -24,30 +24,6 @@ pub use self::queues::{NvmeCmd, NvmeCmdQueue, NvmeComp, NvmeCompQueue}; use pcid_interface::msi::{MappedMsixRegs, MsiInfo}; use pcid_interface::PciFunctionHandle; -#[cfg(target_arch = "aarch64")] -#[inline(always)] -pub(crate) unsafe fn pause() { - std::arch::aarch64::__yield(); -} - -#[cfg(target_arch = "x86")] -#[inline(always)] -pub(crate) unsafe fn pause() { - std::arch::x86::_mm_pause(); -} - -#[cfg(target_arch = "x86_64")] -#[inline(always)] -pub(crate) unsafe fn pause() { - std::arch::x86_64::_mm_pause(); -} - -#[cfg(target_arch = "riscv64")] -#[inline(always)] -pub(crate) unsafe fn pause() { - std::arch::riscv64::pause(); -} - /// Used in conjunction with `InterruptMethod`, primarily by the CQ executor. #[derive(Debug)] pub enum InterruptSources { @@ -299,7 +275,7 @@ impl Nvme { let csts = self.regs.get_mut().csts.read(); log::trace!("CSTS: {:X}", csts); if csts & 1 == 1 { - pause(); + std::hint::spin_loop(); } else { break; } @@ -364,7 +340,7 @@ impl Nvme { let csts = self.regs.get_mut().csts.read(); log::debug!("CSTS: {:X}", csts); if csts & 1 == 0 { - pause(); + std::hint::spin_loop(); } else { break; } diff --git a/storage/nvmed/src/nvme/queues.rs b/storage/nvmed/src/nvme/queues.rs index 9d9cf2e2cb..a3712aeb74 100644 --- a/storage/nvmed/src/nvme/queues.rs +++ b/storage/nvmed/src/nvme/queues.rs @@ -87,7 +87,7 @@ impl NvmeCompQueue { return some; } else { unsafe { - super::pause(); + std::hint::spin_loop(); } } }