Re: [PATCH v19 1/5] rust: Introduce interrupt module
From: Gary Guo
Date: Fri Mar 13 2026 - 09:45:51 EST
On Mon Mar 2, 2026 at 11:16 PM GMT, Lyude Paul wrote:
> This introduces a module for dealing with interrupt-disabled contexts,
> including the ability to enable and disable interrupts along with the
> ability to annotate functions as expecting that IRQs are already
> disabled on the local CPU.
>
> [Boqun: This is based on Lyude's work on interrupt disable abstraction,
> I port to the new local_interrupt_disable() mechanism to make it work
> as a guard type. I cannot even take the credit of this design, since
> Lyude also brought up the same idea in zulip. Anyway, this is only for
> POC purpose, and of course all bugs are mine]
>
> Signed-off-by: Lyude Paul <lyude@xxxxxxxxxx>
> Co-developed-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> Signed-off-by: Boqun Feng <boqun.feng@xxxxxxxxx>
> Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx>
> Reviewed-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
>
> 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.
> V18:
> * Add missing __rust_helper annotations
> V19:
> * Use crate:: instead of kernel::
> * #[inline] all of the things
>
> rust/helpers/helpers.c | 1 +
> rust/helpers/interrupt.c | 18 ++++++++
> rust/helpers/sync.c | 5 +++
> rust/kernel/interrupt.rs | 89 ++++++++++++++++++++++++++++++++++++++++
> rust/kernel/lib.rs | 1 +
> 5 files changed, 114 insertions(+)
> create mode 100644 rust/helpers/interrupt.c
> create mode 100644 rust/kernel/interrupt.rs