[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DF4IE0A2ZGSG.YBG5E9W03V5I@kernel.org>
Date: Mon, 22 Dec 2025 06:50:44 +0100
From: "Benno Lossin" <lossin@...nel.org>
To: "Lyude Paul" <lyude@...hat.com>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, "Thomas Gleixner" <tglx@...utronix.de>
Cc: "Boqun Feng" <boqun.feng@...il.com>, "Daniel Almeida"
<daniel.almeida@...labora.com>, "Miguel Ojeda" <ojeda@...nel.org>, "Alex
Gaynor" <alex.gaynor@...il.com>, "Gary Guo" <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>, "Andreas
Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
"Trevor Gross" <tmgross@...ch.edu>, "Danilo Krummrich" <dakr@...nel.org>,
"Andrew Morton" <akpm@...ux-foundation.org>, "Peter Zijlstra"
<peterz@...radead.org>, "Ingo Molnar" <mingo@...hat.com>, "Will Deacon"
<will@...nel.org>, "Waiman Long" <longman@...hat.com>
Subject: Re: [PATCH v16 09/17] rust: sync: Add SpinLockIrq
On Mon Dec 15, 2025 at 6:57 PM CET, Lyude Paul wrote:
> A variant of SpinLock that is expected to be used in noirq contexts, so
You say in the next line that `lock` automatically disables interrupts,
so you also should be able to use the lock in contexts with interrupts,
right? Feel like this would be better summarized as
A variant of `SpinLock` that ensures interrupts are disabled in the
critical section. `lock()` will ensure that either interrupts are
already disabled or disable them. `unlock()` will reverse the
respective operation.
> lock() will disable interrupts and unlock() (i.e. `Guard::drop()` will
> undo the interrupt disable.
>
> [Boqun: Port to use spin_lock_irq_disable() and
> spin_unlock_irq_enable()]
>
> Signed-off-by: Lyude Paul <lyude@...hat.com>
> Co-developed-by: Boqun Feng <boqun.feng@...il.com>
> Signed-off-by: Boqun Feng <boqun.feng@...il.com>
> Reviewed-by: Andreas Hindborg <a.hindborg@...nel.org>
> +/// A spinlock that may be acquired when local processor interrupts are disabled.
Similarly here, I would reuse the first sentence (or a variant of it)
that I gave above.
Aside from Gary's comments, this patch looks good:
Reviewed-by: Benno Lossin <lossin@...nel.org>
Cheers,
Benno
> +///
> +/// This is a version of [`SpinLock`] that can only be used in contexts where interrupts for the
> +/// local CPU are disabled. It can be acquired in two ways:
> +///
> +/// - Using [`lock()`] like any other type of lock, in which case the bindings will modify the
> +/// interrupt state to ensure that local processor interrupts remain disabled for at least as long
> +/// as the [`SpinLockIrqGuard`] exists.
> +/// - Using [`lock_with()`] in contexts where a [`LocalInterruptDisabled`] token is present and
> +/// local processor interrupts are already known to be disabled, in which case the local interrupt
> +/// state will not be touched. This method should be preferred if a [`LocalInterruptDisabled`]
> +/// token is present in the scope.
Powered by blists - more mailing lists