[PATCH v16 08/17] rust: helper: Add spin_{un,}lock_irq_{enable,disable}() helpers

Lyude Paul posted 17 patches 3 days, 21 hours ago
[PATCH v16 08/17] rust: helper: Add spin_{un,}lock_irq_{enable,disable}() helpers
Posted by Lyude Paul 3 days, 21 hours ago
From: Boqun Feng <boqun.feng@gmail.com>

spin_lock_irq_disable() and spin_unlock_irq_enable() are inline
functions, to use them in Rust, helpers are introduced. This is for
interrupt disabling lock abstraction in Rust.

Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Signed-off-by: Lyude Paul <lyude@redhat.com>
---
 rust/helpers/spinlock.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c
index 42c4bf01a23e4..d4e61057c2a7a 100644
--- a/rust/helpers/spinlock.c
+++ b/rust/helpers/spinlock.c
@@ -35,3 +35,18 @@ void rust_helper_spin_assert_is_held(spinlock_t *lock)
 {
 	lockdep_assert_held(lock);
 }
+
+void rust_helper_spin_lock_irq_disable(spinlock_t *lock)
+{
+	spin_lock_irq_disable(lock);
+}
+
+void rust_helper_spin_unlock_irq_enable(spinlock_t *lock)
+{
+	spin_unlock_irq_enable(lock);
+}
+
+int rust_helper_spin_trylock_irq_disable(spinlock_t *lock)
+{
+	return spin_trylock_irq_disable(lock);
+}
-- 
2.52.0
Re: [PATCH v16 08/17] rust: helper: Add spin_{un,}lock_irq_{enable,disable}() helpers
Posted by Gary Guo 3 days, 3 hours ago
On Mon, 15 Dec 2025 12:57:55 -0500
Lyude Paul <lyude@redhat.com> wrote:

> From: Boqun Feng <boqun.feng@gmail.com>
> 
> spin_lock_irq_disable() and spin_unlock_irq_enable() are inline
> functions, to use them in Rust, helpers are introduced. This is for
> interrupt disabling lock abstraction in Rust.
> 
> Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
> Signed-off-by: Lyude Paul <lyude@redhat.com>
> ---
>  rust/helpers/spinlock.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c
> index 42c4bf01a23e4..d4e61057c2a7a 100644
> --- a/rust/helpers/spinlock.c
> +++ b/rust/helpers/spinlock.c
> @@ -35,3 +35,18 @@ void rust_helper_spin_assert_is_held(spinlock_t *lock)
>  {
>  	lockdep_assert_held(lock);
>  }
> +
> +void rust_helper_spin_lock_irq_disable(spinlock_t *lock)
> +{
> +	spin_lock_irq_disable(lock);
> +}
> +
> +void rust_helper_spin_unlock_irq_enable(spinlock_t *lock)
> +{
> +	spin_unlock_irq_enable(lock);
> +}
> +
> +int rust_helper_spin_trylock_irq_disable(spinlock_t *lock)
> +{
> +	return spin_trylock_irq_disable(lock);
> +}

Can you add __rust_helper prefix to these helpers please.

Best,
Gary