Add InAtomicMode: Debug

This commit is contained in:
Zhang Junyang 2025-05-22 20:55:57 +08:00 committed by Tate, Hongliang Tian
parent 3472560c55
commit ef81100958
2 changed files with 7 additions and 6 deletions

View File

@ -50,17 +50,17 @@ pub fn might_sleep() {
///
/// Key kernel primitives such as `SpinLock` and `Rcu` rely on
/// [the atomic mode](crate::task::atomic_mode) for correctness or soundness.
/// The existence of such a guard guarantees that
/// the current task is executing in the atomic mode.
/// The existence of such a guard guarantees that the current task is executing
/// in the atomic mode.
///
/// It requires [`core::fmt::Debug`] by default to make it easier to derive
/// [`Debug`] for types with `&dyn InAtomicMode`.
///
/// # Safety
///
/// The implementer must ensure that the atomic mode is maintained while
/// the guard type is alive.
///
/// [`DisabledLocalIrqGuard`]: crate::task::DisabledPreemptGuard
/// [`DisabledPreemptGuard`]: crate::trap::DisabledLocalIrqGuard
pub unsafe trait InAtomicMode {}
pub unsafe trait InAtomicMode: core::fmt::Debug {}
/// Abstracts any type from which one can obtain a reference to an atomic-mode guard.
pub trait AsAtomicModeGuard {

View File

@ -139,6 +139,7 @@ pub fn disable_local() -> DisabledLocalIrqGuard {
/// A guard for disabled local IRQs.
#[clippy::has_significant_drop]
#[must_use]
#[derive(Debug)]
pub struct DisabledLocalIrqGuard {
was_enabled: bool,
}