[PATCH v18 0/5] SpinLockIrq for rust

Lyude Paul posted 5 patches 1 day, 14 hours ago
rust/helpers/helpers.c            |   1 +
rust/helpers/interrupt.c          |  18 ++
rust/helpers/spinlock.c           |  15 ++
rust/helpers/sync.c               |   5 +
rust/kernel/interrupt.rs          |  86 ++++++++
rust/kernel/lib.rs                |   1 +
rust/kernel/sync.rs               |   4 +-
rust/kernel/sync/lock/global.rs   |   3 +
rust/kernel/sync/lock/spinlock.rs | 313 +++++++++++++++++++++++++++++-
9 files changed, 440 insertions(+), 6 deletions(-)
create mode 100644 rust/helpers/interrupt.c
create mode 100644 rust/kernel/interrupt.rs
[PATCH v18 0/5] SpinLockIrq for rust
Posted by Lyude Paul 1 day, 14 hours ago
This is the latest patch series for adding rust bindings for controlling
local processor interrupts, adding support for spinlocks in rust that
are acquired with local processor interrupts disabled, and implementing
local interrupt controls through refcounting in the kernel.

The previous version of this patch series can be found here:

  https://lore.kernel.org/all/20260121223933.1568682-1-lyude@redhat.com/

This patch series applies on top of boqun's rust-sync branch:

  https://git.kernel.org/pub/scm/linux/kernel/git/boqun/linux.git/?h=rust-sync

Now that we've gotten the C-side of these changes in, this patch series
is now exclusively concerned with the rust side of these changes. For
more information on how we came to the design for the C side of the API,
see the explanation in the previous version of the patch series.

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

			    FULL CHANGELOG:

Series-wide:
  V15:
    * Added a patch for fixing build erors introduced on OpenRISC
  V17:
    * Squash:
      - "rust: sync: Introduce lock::Backend::Context"
      - "rust: sync: lock: Add `Backend::BackendInContext`"
      With BackendWithContext being a separate trait, it no longer makes
      sense for these patches to be separate.
  V18:
    * Add "rust: sync: use super::* in spinlock.rs"

Patch-specific:
  * rust: Introduce interrupt module
    V10:
      * Fix documentation typos
    V11:
      * Get rid of unneeded `use bindings;`
      * Move ASSUME_DISABLED into assume_disabled()
      * Confirm using lockdep_assert_irqs_disabled() that local interrupts are
        in fact disabled when LocalInterruptDisabled::assume_disabled() is called.
  * rust: helper: Add spin_{un,}lock_irq_{enable,disable}() helpers
    V18:
      * Add missing __rust_helper annotations
  * rust: sync: Add SpinLockIrq
    V10:
      * Also add support to GlobalLock
      * Documentation fixes from Dirk
    V11:
      * Add unit test requested by Daniel Almeida
    V14:
      * Improve rustdoc for SpinLockIrqBackend
    V18:
      * Add missing __rust_helper annotations
  * rust: sync: Introduce SpinLockIrq::lock_with() and friends
    V10:
      * Fix typos - Dirk
    V17:
      * Introduce `BackendWithContext`, move context-related bits into there and
        out of `Backend`.
      * Add missing #[must_use = …] for try_lock_with()
      * Remove all unsafe code from lock_with() and try_lock_with():
        Somehow I never noticed that literally none of the unsafe code in these
        two functions is needed with as_lock_in_context()...
    V18:
      * Drop the traits, just implement this on SpinLockIrq
  * rust: sync: Expose lock::Backend
    V10:
      * Fix typos - Dirk/Lyude
      * Since we're adding support for context locks to GlobalLock as well, let's
        also make sure to cover try_lock while we're at it and add try_lock_with
      * Add a private function as_lock_in_context() for handling casting from a
        Lock<T, B> to Lock<T, B::BackendInContext> so we don't have to duplicate
        safety comments
    V11:
      * Fix clippy::ref_as_ptr error in Lock::as_lock_in_context()
    V14:
      * Add benchmark results, rewrite commit message
  * rust: sync: lock/global: Rename B to G in trait bounds
  * rust: sync: Add a lifetime parameter to lock::global::GlobalGuard
  * rust: sync: lock/global: Add Backend parameter to GlobalGuard
    V17:
      * Add default parameter for generic `B` to `GlobalGuard`
  * rust: sync: lock/global: Add ContextualBackend support to GlobalLock
  * locking: Switch to _irq_{disable,enable}() variants in cleanup guards
    V10:
      * Add PREEMPT_RT build fix from Guangbo Cui

 rust/helpers/helpers.c            |   1 +
 rust/helpers/interrupt.c          |  18 ++
 rust/helpers/spinlock.c           |  15 ++
 rust/helpers/sync.c               |   5 +
 rust/kernel/interrupt.rs          |  86 ++++++++
 rust/kernel/lib.rs                |   1 +
 rust/kernel/sync.rs               |   4 +-
 rust/kernel/sync/lock/global.rs   |   3 +
 rust/kernel/sync/lock/spinlock.rs | 313 +++++++++++++++++++++++++++++-
 9 files changed, 440 insertions(+), 6 deletions(-)
 create mode 100644 rust/helpers/interrupt.c
 create mode 100644 rust/kernel/interrupt.rs



base-commit: de718b2ca866e10e2a26c259ab0493a5af411879
-- 
2.53.0