[PATCH 6.18.y 0/6] Backport spin_lock_irq_disable() to 6.18.y

From: Alice Ryhl

Date: Thu Oct 15 2026 - 04:19:37 EST


This series backports the new spin_lock_irq_disable() API, as well as
the new SpinLockIrq API for Rust to 6.18.y. This means that any upstream
code using these APIs can be backported cleanly to 6.18.y without
needing adjustment to work using the old APIs.

The first commit uses a different implementation than upstream commit
e901c1510e24 ("irq,spin_lock: Add counted interrupt
disabling/enabling"). In mainline, `local_interrupt_enable()` works by
carving `HARDIRQ_DISABLE_BITS` out of `preempt_count`, which requires
reworking the `preempt_count` layout and arch-specific accessors across
x86, arm64, and s390. Instead of backporting those invasive changes to
6.18.y, patch 1 implements the same refcounted interrupt disabling API
using a dedicated per-CPU nesting counter and saved irqflags word. This
is slightly less efficient, but is much less invasive. Patches 2-6 are
clean cherry-picks of the upstream patches.

Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
---
Alice Ryhl (1):
irq: Add refcounted local interrupt disabling

Boqun Feng (1):
rust: helper: Add spin_{un,}lock_irq_{enable,disable}() helpers

Lyude Paul (4):
rust: Introduce interrupt module
rust: sync: Use super::* in spinlock.rs
rust: sync: Add SpinLockIrq
rust: sync: Introduce SpinLockIrq::lock_with() and friends

include/linux/interrupt_rc.h | 26 +++
include/linux/spinlock.h | 61 +++++++
kernel/softirq.c | 63 ++++++++
rust/helpers/helpers.c | 1 +
rust/helpers/interrupt.c | 13 ++
rust/helpers/spinlock.c | 15 ++
rust/helpers/sync.c | 5 +
rust/kernel/interrupt.rs | 89 +++++++++++
rust/kernel/lib.rs | 1 +
rust/kernel/sync.rs | 9 +-
rust/kernel/sync/lock/global.rs | 3 +
rust/kernel/sync/lock/spinlock.rs | 329 +++++++++++++++++++++++++++++++++++++-
12 files changed, 609 insertions(+), 6 deletions(-)
---
base-commit: 17ad2612c11a748b50d32eefc681344b26fea946
change-id: 20261013-spinlock-irq-6-18-9720cdb14be6

Best regards,
--
Alice Ryhl <aliceryhl@xxxxxxxxxx>