feat(thread): add interrupt mode and FdGroup API wrappers#105
Merged
mergify[bot] merged 5 commits intoopenebs:developfrom Apr 21, 2026
Merged
feat(thread): add interrupt mode and FdGroup API wrappers#105mergify[bot] merged 5 commits intoopenebs:developfrom
mergify[bot] merged 5 commits intoopenebs:developfrom
Conversation
This was referenced Apr 12, 2026
tiagolobocastro
approved these changes
Apr 14, 2026
Member
tiagolobocastro
left a comment
There was a problem hiding this comment.
We'll have to merge the dependent PR before this one, I'll try to review it a little later today
Abhinandan-Purkait
approved these changes
Apr 14, 2026
Add safe Rust wrappers for SPDK's interrupt mode facility (available since SPDK 24.09) and the fd_group hierarchical event multiplexing API. New Thread methods: - interrupt_mode_enable/is_enabled: global init and query - set_interrupt_mode: per-thread poll/interrupt switching - get_interrupt_fd/get_interrupt_fd_group: access thread event fds New FdGroup struct with RAII lifecycle: - create/wait/nest/unnest: hierarchical event multiplexing - add/add_with_fd_type: fd registration with optional auto-drain New FD_TYPE_EVENTFD constant for auto-draining eventfds in fd_group_wait. These APIs enable custom reactors to sleep in fd_group_wait() instead of busy-polling, reducing CPU usage from ~100% to near-zero when idle. Ref: openebs/mayastor#1745 Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
da98c7a to
5c30902
Compare
jr42
added a commit
to jr42/mayastor
that referenced
this pull request
Apr 18, 2026
Update spdk-rs submodule to include FdGroup wrapper and Thread interrupt mode API wrappers required by the reactor interrupt mode implementation. spdk-rs also bumps its libspdk nix pin to pull in the iSCSI poll group interrupt registration and bdev wait_for_examine periodic poller fixes on the SPDK side (openebs/spdk#70), required for interrupt mode with custom reactors. Depends-On: openebs/spdk-rs#105 Depends-On: openebs/spdk#70 Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/mayastor
that referenced
this pull request
Apr 18, 2026
Update spdk-rs submodule to include FdGroup wrapper and Thread interrupt mode API wrappers required by the reactor interrupt mode implementation. spdk-rs also bumps its libspdk nix pin to pull in the iSCSI poll group interrupt registration and bdev wait_for_examine periodic poller fixes on the SPDK side (openebs/spdk#70), required for interrupt mode with custom reactors. Depends-On: openebs/spdk-rs#105 Depends-On: openebs/spdk#70 Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/spdk-rs
that referenced
this pull request
Apr 18, 2026
Addresses openebs#105 review from @tiagolobocastro ("Should we return `nix::Error` here? and throughout"). Converts `FdGroup::create`, `add`, `add_with_fd_type`, `nest`, `unnest` and `Thread::interrupt_mode_enable` from `Result<_, i32>` to `Result<_, Errno>`, matching the idiom used elsewhere in this crate (`src/bdev.rs`, `src/ffihelper.rs`). Left `FdGroup::wait()` on raw `i32` — it returns a non-negative event count on success, so the Result-shape doesn't fit. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/mayastor
that referenced
this pull request
Apr 18, 2026
Addresses PR openebs#1966 review (openebs/spdk-rs#105 review thread from @tiagolobocastro). spdk-rs' FdGroup methods and `Thread::interrupt_mode_enable` now return `Result<_, nix::Errno>` instead of `Result<_, i32>`, matching the idiom used elsewhere in that crate. Update every call site in reactor.rs to drop the `rc` positional formatting and use the `Errno`'s Display impl directly in error messages, and tighten the interrupt_mode_enable startup path to `.expect(...)` rather than `assert_eq!(rc, 0, ...)`. Bumps spdk-rs submodule to the commit that introduces the new signatures. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/spdk-rs
that referenced
this pull request
Apr 18, 2026
Addresses openebs#105 review from @tiagolobocastro. Only `FdGroup::create()` constructs the struct and it always sets `owned: true`; Drop now unconditionally destroys. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/mayastor
that referenced
this pull request
Apr 18, 2026
Addresses PR openebs#1966 review (openebs/spdk-rs#105 review thread from @tiagolobocastro). spdk-rs' FdGroup methods and `Thread::interrupt_mode_enable` now return `Result<_, nix::Errno>` instead of `Result<_, i32>`, matching the idiom used elsewhere in that crate. Update every call site in reactor.rs to drop the `rc` positional formatting and use the `Errno`'s Display impl directly in error messages, and tighten the interrupt_mode_enable startup path to `.expect(...)` rather than `assert_eq!(rc, 0, ...)`. Bumps spdk-rs submodule to the commit that introduces the new signatures. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/spdk-rs
that referenced
this pull request
Apr 18, 2026
Addresses openebs#105 review from @tiagolobocastro. Adds `spdk_fd_type` to the bindgen allowlist so `SPDK_FD_TYPE_EVENTFD` lands in `libspdk.rs` as a module-level const — same pattern as `SPDK_BDEV_IO_TYPE_*` / `SPDK_BDEV_RESET_STAT_*`. Drops the mirror constant from the public thread API. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/mayastor
that referenced
this pull request
Apr 18, 2026
Follow-up to openebs/spdk-rs#105 exposing the SPDK fd_type enum directly via bindgen. Drops the `spdk_rs::FD_TYPE_EVENTFD` mirror reference in favour of `spdk_rs::libspdk::SPDK_FD_TYPE_EVENTFD`. Bumps spdk-rs submodule. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/spdk-rs
that referenced
this pull request
Apr 20, 2026
Addresses openebs#105 review from @tiagolobocastro ("Should we return `nix::Error` here? and throughout"). Converts `FdGroup::create`, `add`, `add_with_fd_type`, `nest`, `unnest` and `Thread::interrupt_mode_enable` from `Result<_, i32>` to `Result<_, Errno>`, matching the idiom used elsewhere in this crate (`src/bdev.rs`, `src/ffihelper.rs`). Left `FdGroup::wait()` on raw `i32` — it returns a non-negative event count on success, so the Result-shape doesn't fit. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/spdk-rs
that referenced
this pull request
Apr 20, 2026
Addresses openebs#105 review from @tiagolobocastro. Only `FdGroup::create()` constructs the struct and it always sets `owned: true`; Drop now unconditionally destroys. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/spdk-rs
that referenced
this pull request
Apr 20, 2026
Addresses openebs#105 review from @tiagolobocastro. Adds `spdk_fd_type` to the bindgen allowlist so `SPDK_FD_TYPE_EVENTFD` lands in `libspdk.rs` as a module-level const — same pattern as `SPDK_BDEV_IO_TYPE_*` / `SPDK_BDEV_RESET_STAT_*`. Drops the mirror constant from the public thread API. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/mayastor
that referenced
this pull request
Apr 20, 2026
Follow-up to openebs/spdk-rs#105 exposing the SPDK fd_type enum directly via bindgen. Drops the `spdk_rs::FD_TYPE_EVENTFD` mirror reference in favour of `spdk_rs::libspdk::SPDK_FD_TYPE_EVENTFD`. Bumps spdk-rs submodule. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
Update SPDK revision to include iSCSI poll group interrupt registration and bdev wait_for_examine periodic poller fix, both required for interrupt mode with custom reactors. Pin targets jr42/spdk@pr/interrupt-mode-fixes (approved but not yet merged upstream). When openebs/spdk#70 lands on openebs/v25.05.x-mayastor, flip owner back to "openebs" and update rev/sha256 to the merged commit. Depends-On: openebs/spdk#70 Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
Addresses openebs#105 review from @tiagolobocastro ("Should we return `nix::Error` here? and throughout"). Converts `FdGroup::create`, `add`, `add_with_fd_type`, `nest`, `unnest` and `Thread::interrupt_mode_enable` from `Result<_, i32>` to `Result<_, Errno>`, matching the idiom used elsewhere in this crate (`src/bdev.rs`, `src/ffihelper.rs`). Left `FdGroup::wait()` on raw `i32` — it returns a non-negative event count on success, so the Result-shape doesn't fit. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
Addresses openebs#105 review from @tiagolobocastro. Only `FdGroup::create()` constructs the struct and it always sets `owned: true`; Drop now unconditionally destroys. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
Addresses openebs#105 review from @tiagolobocastro. Adds `spdk_fd_type` to the bindgen allowlist so `SPDK_FD_TYPE_EVENTFD` lands in `libspdk.rs` as a module-level const — same pattern as `SPDK_BDEV_IO_TYPE_*` / `SPDK_BDEV_RESET_STAT_*`. Drops the mirror constant from the public thread API. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
jr42
added a commit
to jr42/mayastor
that referenced
this pull request
Apr 21, 2026
Follow-up to openebs/spdk-rs#105 exposing the SPDK fd_type enum directly via bindgen. Drops the `spdk_rs::FD_TYPE_EVENTFD` mirror reference in favour of `spdk_rs::libspdk::SPDK_FD_TYPE_EVENTFD`. Bumps spdk-rs submodule. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
Member
|
@mergify queue |
Contributor
|
Deprecation notice: This pull request comes from a fork and was queued with |
Contributor
Merge Queue Status
This pull request spent 12 seconds in the queue, including 3 seconds running CI. Required conditions to merge
|
jr42
added a commit
to jr42/mayastor
that referenced
this pull request
Apr 21, 2026
Follow-up to openebs/spdk-rs#105 exposing the SPDK fd_type enum directly via bindgen. Drops the `spdk_rs::FD_TYPE_EVENTFD` mirror reference in favour of `spdk_rs::libspdk::SPDK_FD_TYPE_EVENTFD`. Bumps spdk-rs submodule. Signed-off-by: Jeremias Reith <jr42@users.noreply.github.com>
bors-openebs-mayastor Bot
pushed a commit
to openebs/mayastor
that referenced
this pull request
Apr 24, 2026
1966: feat(reactor): add SPDK interrupt mode support r=tiagolobocastro a=jr42 ## Summary Opt-in SPDK interrupt mode for io-engine: reactors sleep in `fd_group_wait()` instead of busy-polling, reducing CPU from ~1000m per core to <300m when idle. - Enable with `ENABLE_INTERRUPT_MODE=true` (default: off, backward compatible) - Follows Longhorn v2 hybrid pattern (LEP 2025-07-21): epoll for NVMe-oF TCP targets, timerfd polling for NVMe initiators - Includes pytest compose wiring for interrupt mode testing ### Implementation Reactor changes (`reactor.rs`, +271 lines): - New `ReactorState::Interrupt` with `fd_group_wait`-based event loop - Reactor-level `FdGroup` nests all thread fd_groups for hierarchical mux - Wakeup eventfd (`FD_TYPE_EVENTFD`, auto-drained) for Rust future delivery - Cross-core wake on thread schedule to prevent multi-core init deadlock - Late fd_group nesting in `add_incoming()` for dynamic thread assignment - Clean shutdown path restoring poll mode ### Why interrupt mode instead of SPDK's dynamic scheduler (#1745) Mayastor implements its own reactor loop (`reactor.rs`), bypassing SPDK's stock reactor entirely. SPDK's dynamic scheduler monitors thread busyness *within SPDK's reactor* -- since mayastor's reactor replaces it, the scheduler has nothing to observe or control. Instead, we implement interrupt mode directly in the custom reactor, following the same pattern validated by Longhorn v2 (LEP 2025-07-21). This is simpler, more predictable, and doesn't require restructuring the reactor to use SPDK's scheduler infrastructure. The dynamic scheduler remains a future option if the reactor is ever migrated closer to SPDK's stock implementation. Depends-On: openebs/spdk-rs#105 Depends-On: openebs/spdk#70 Closes: #1745 ## Test plan - [x] 73/86 pytest tests pass in single-core interrupt mode (13 failures are env-related, identical in poll mode) - [x] Multi-core validated (2-core smoke test) - [x] Production: 3-node cluster, 16 volumes, CPU ~3000m to ~463m (85% reduction) - [x] Rolling restart validated: volumes auto-recover, nexuses redistribute - [ ] CI pipeline passes Co-authored-by: Jeremias Reith <jr42@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Safe Rust wrappers for SPDK's interrupt mode facility and fd_group
hierarchical event multiplexing API (available since SPDK 24.09),
enabling custom reactors to sleep in
fd_group_wait()instead ofbusy-polling.
New Thread methods:
interrupt_mode_enable()/interrupt_mode_is_enabled(): global init and queryset_interrupt_mode(enable): per-thread poll/interrupt switchingget_interrupt_fd()/get_interrupt_fd_group(): access thread event fdsNew FdGroup struct with RAII lifecycle:
create()/Drop: lifecycle managementwait(timeout): block until events (fd_group_wait)nest(child)/unnest(child): hierarchical event multiplexingadd()/add_with_fd_type(): fd registration with optional auto-drainNew constant:
FD_TYPE_EVENTFD: marks eventfds for auto-draining infd_group_wait()These APIs enable the mayastor reactor to implement interrupt mode,
reducing CPU from ~1000m per core to <300m when idle.
Depends-On: openebs/spdk#70 (iSCSI + bdev interrupt fixes)
Ref: openebs/mayastor#1745
Test plan