Skip to content

refactor(interrupts): construct handler mappings during device init#2473

Merged
mkroening merged 1 commit into
hermit-os:mainfrom
cagatay-y:refactor-int-at-init
Jun 26, 2026
Merged

refactor(interrupts): construct handler mappings during device init#2473
mkroening merged 1 commit into
hermit-os:mainfrom
cagatay-y:refactor-int-at-init

Conversation

@cagatay-y

Copy link
Copy Markdown
Contributor

MSI-X will require support for more than one interrupt vector per driver and more information from the driver side to decide how to handle the interrupts correctly. Revise how the mappings are constructed to make the construction more flexible and prepare for that use case.

@mkroening mkroening self-assigned this Jun 9, 2026
@mkroening mkroening self-requested a review June 9, 2026 13:10

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark Results

Details
Benchmark Current: b2838e5 Previous: 3fddec8 Performance Ratio
startup_benchmark Build Time 77.40 s 77.54 s 1.00
startup_benchmark File Size 0.77 MB 0.77 MB 1.00
Startup Time - 1 core 0.75 s (±0.02 s) 0.74 s (±0.02 s) 1.00
Startup Time - 2 cores 0.74 s (±0.02 s) 0.74 s (±0.02 s) 1.00
Startup Time - 4 cores 0.74 s (±0.02 s) 0.74 s (±0.02 s) 1.00
multithreaded_benchmark Build Time 79.03 s 78.02 s 1.01
multithreaded_benchmark File Size 0.87 MB 0.83 MB 1.04
Multithreaded Pi Efficiency - 2 Threads 87.98 % (±7.06 %) 88.15 % (±10.12 %) 1.00
Multithreaded Pi Efficiency - 4 Threads 43.84 % (±2.80 %) 44.00 % (±2.70 %) 1.00
Multithreaded Pi Efficiency - 8 Threads 25.52 % (±1.27 %) 25.61 % (±1.15 %) 1.00
micro_benchmarks Build Time 78.56 s 78.90 s 1.00
micro_benchmarks File Size 0.87 MB 0.83 MB 1.04
Scheduling time - 1 thread 65.78 ticks (±2.50 ticks) 63.55 ticks (±2.19 ticks) 1.04
Scheduling time - 2 threads 35.03 ticks (±3.48 ticks) 37.36 ticks (±5.81 ticks) 0.94
Micro - Time for syscall (getpid) 3.34 ticks (±0.54 ticks) 3.42 ticks (±0.66 ticks) 0.98
Memcpy speed - (built_in) block size 4096 82491.13 MByte/s (±57337.46 MByte/s) 85755.51 MByte/s (±59154.88 MByte/s) 0.96
Memcpy speed - (built_in) block size 1048576 30864.70 MByte/s (±24833.00 MByte/s) 30798.00 MByte/s (±24808.58 MByte/s) 1.00
Memcpy speed - (built_in) block size 16777216 27680.72 MByte/s (±22873.02 MByte/s) 27735.11 MByte/s (±22922.42 MByte/s) 1.00
Memset speed - (built_in) block size 4096 82666.97 MByte/s (±57435.51 MByte/s) 85561.11 MByte/s (±59022.96 MByte/s) 0.97
Memset speed - (built_in) block size 1048576 31599.45 MByte/s (±25274.35 MByte/s) 31540.44 MByte/s (±25246.30 MByte/s) 1.00
Memset speed - (built_in) block size 16777216 28478.29 MByte/s (±23379.32 MByte/s) 28522.65 MByte/s (±23408.89 MByte/s) 1.00
Memcpy speed - (rust) block size 4096 76981.89 MByte/s (±53610.29 MByte/s) 76278.05 MByte/s (±53195.57 MByte/s) 1.01
Memcpy speed - (rust) block size 1048576 30689.11 MByte/s (±24813.32 MByte/s) 30571.08 MByte/s (±24694.20 MByte/s) 1.00
Memcpy speed - (rust) block size 16777216 28015.11 MByte/s (±23151.44 MByte/s) 27092.68 MByte/s (±22306.35 MByte/s) 1.03
Memset speed - (rust) block size 4096 77428.31 MByte/s (±53927.51 MByte/s) 77081.89 MByte/s (±53714.43 MByte/s) 1.00
Memset speed - (rust) block size 1048576 31450.78 MByte/s (±25261.92 MByte/s) 31329.56 MByte/s (±25140.07 MByte/s) 1.00
Memset speed - (rust) block size 16777216 28814.21 MByte/s (±23653.36 MByte/s) 27893.05 MByte/s (±22822.05 MByte/s) 1.03
alloc_benchmarks Build Time 73.04 s 74.00 s 0.99
alloc_benchmarks File Size 0.85 MB 0.86 MB 1.00
Allocations - Allocation success 91.32 % 91.32 % 1
Allocations - Deallocation success 100.00 % 100.00 % 1
Allocations - Pre-fail Allocations 61.46 % 61.46 % 1
Allocations - Average Allocation time 2736.03 Ticks (±405.51 Ticks) 2517.26 Ticks (±526.46 Ticks) 1.09
Allocations - Average Allocation time (no fail) 3736.99 Ticks (±349.82 Ticks) 3544.10 Ticks (±455.05 Ticks) 1.05
Allocations - Average Deallocation time 859.27 Ticks (±92.57 Ticks) 674.85 Ticks (±85.89 Ticks) 1.27
mutex_benchmark Build Time 75.04 s 74.68 s 1.00
mutex_benchmark File Size 0.87 MB 0.84 MB 1.04
Mutex Stress Test Average Time per Iteration - 1 Threads 11.94 ns (±0.37 ns) 12.00 ns (±0.20 ns) 0.99
Mutex Stress Test Average Time per Iteration - 2 Threads 38.48 ns (±3.00 ns) 39.30 ns (±3.77 ns) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

@cagatay-y cagatay-y force-pushed the refactor-int-at-init branch from 4e80af2 to e6f7301 Compare June 23, 2026 11:59

@mkroening mkroening left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand a bit on the overall design and how it is necessitated by MSI-X?

Why have fn init_dev(&mut self, handlers: &mut Map, irq: Option<Irq>) instead of fn interrupts(&self) -> impl Iterator<Item = Irq>, for example?

Comment thread src/arch/aarch64/kernel/interrupts.rs Outdated
Comment thread src/arch/x86_64/kernel/interrupts.rs Outdated
Comment thread src/arch/x86_64/kernel/interrupts.rs Outdated
Comment thread src/arch/aarch64/kernel/mmio.rs
Comment thread src/arch/riscv64/kernel/devicetree.rs Outdated
Comment thread src/drivers/virtio/transport/mmio.rs
Comment thread src/drivers/virtio/transport/pci.rs Outdated
Comment thread src/drivers/mmio.rs
Comment thread src/drivers/pci.rs Outdated
@cagatay-y

Copy link
Copy Markdown
Contributor Author

Why have fn init_dev(&mut self, handlers: &mut Map, irq: Option<Irq>) instead of fn interrupts(&self) -> impl Iterator<Item = Irq>, for example?

MSI-X can have different interrupt vectors for device configuration interrupts and different queues. An implementation that uses an iterator based approach would require the caller to have a lot of knowledge about the functioning of the device, for example which number is for which kind of queue, which queues we are interested in the interrupts of, etc. An iterator that returns vector-handler pairs could overcome this issue but giving the drivers access to the handler mapping allows the drivers to determine which spots are free and thus avoid vector collisions, reducing the latency for handling.

@cagatay-y cagatay-y force-pushed the refactor-int-at-init branch 2 times, most recently from c6148ef to b73c1f6 Compare June 25, 2026 14:16
MSI-X will require support for more than one interrupt vector per driver
and more information from the driver side to decide how to handle the
interrupts correctly. Revise how the mappings are constructed to make
the construction more flexible and prepare for that use case.
@cagatay-y cagatay-y force-pushed the refactor-int-at-init branch from b73c1f6 to b2838e5 Compare June 26, 2026 00:16

@mkroening mkroening left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! :)

@mkroening mkroening added this pull request to the merge queue Jun 26, 2026
Merged via the queue into hermit-os:main with commit d0cad29 Jun 26, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants