Skip to content

Conversation

zyuiop
Copy link
Contributor

@zyuiop zyuiop commented Jul 7, 2025

This PR adds an ioctl handler to file descriptor objects, such as sockets, and a helper to register any ioctl handler at a particular file system path.

Some Linux-specific crates communicate with the kernel via the use of an ioctl file. Support of ioctls may provide an easy path when porting such libraries to work with hermit, without increasing too much the size of the ABI for too specific features.

@zyuiop zyuiop force-pushed the feat/ioctl branch 2 times, most recently from 5b8f40e to fa34f51 Compare July 7, 2025 12:37
@mkroening mkroening self-requested a review July 7, 2025 12:56
@mkroening mkroening self-assigned this Jul 7, 2025
src/fs/ioctl.rs Outdated
Comment on lines 12 to 13
#[derive(Copy, Clone)]
pub struct IoCtlCall(pub u32);
Copy link
Member

Choose a reason for hiding this comment

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

We could use bitfield-struct for these bitfield types, which is already a transitive dependency.

We should link to the reference header (this one?) in the doc comments of this struct.

@zyuiop zyuiop requested a review from mkroening July 8, 2025 16:15
@zyuiop zyuiop force-pushed the feat/ioctl branch 2 times, most recently from 0922143 to d4b9e27 Compare July 28, 2025 10:05
@zyuiop
Copy link
Contributor Author

zyuiop commented Jul 28, 2025

@mkroening it should be good now, I rebased and my new tests pass :)

edit: not sure what the failing test is nor why it fails...

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Benchmark Results

Benchmark Current: 2fb90fa Previous: 8ed91fe Performance Ratio
startup_benchmark Build Time 90.33 s 89.11 s 1.01
startup_benchmark File Size 0.90 MB 0.90 MB 1.00
Startup Time - 1 core 0.89 s (±0.03 s) 0.91 s (±0.02 s) 0.98
Startup Time - 2 cores 0.90 s (±0.02 s) 0.91 s (±0.02 s) 1.00
Startup Time - 4 cores 0.91 s (±0.02 s) 0.92 s (±0.02 s) 0.99
multithreaded_benchmark Build Time 91.75 s 87.92 s 1.04
multithreaded_benchmark File Size 1.00 MB 1.00 MB 1.00
Multithreaded Pi Efficiency - 2 Threads 3.41 % (±16.38 %) 3.44 % (±16.53 %) 0.99
Multithreaded Pi Efficiency - 4 Threads 1.78 % (±8.53 %) 1.56 % (±7.47 %) 1.14
Multithreaded Pi Efficiency - 8 Threads 0.98 % (±4.69 %) 0.97 % (±4.67 %) 1.00
micro_benchmarks Build Time 92.08 s 94.61 s 0.97
micro_benchmarks File Size 1.00 MB 1.00 MB 1.00
Scheduling time - 1 thread 2.15 ticks (±10.30 ticks) 2.64 ticks (±12.67 ticks) 0.81
Scheduling time - 2 threads 1.30 ticks (±6.25 ticks) 1.41 ticks (±6.78 ticks) 0.92
Micro - Time for syscall (getpid) 0.60 ticks (±2.88 ticks) 0.63 ticks (±3.03 ticks) 0.95
Memcpy speed - (built_in) block size 4096 1516.99 MByte/s (±7281.55 MByte/s) 1370.61 MByte/s (±6578.95 MByte/s) 1.11
Memcpy speed - (built_in) block size 1048576 746.66 MByte/s (±3583.96 MByte/s) 705.85 MByte/s (±3388.10 MByte/s) 1.06
Memcpy speed - (built_in) block size 16777216 219.68 MByte/s (±1054.45 MByte/s) 222.48 MByte/s (±1067.91 MByte/s) 0.99
Memset speed - (built_in) block size 4096 1846.15 MByte/s (±8861.54 MByte/s) 1818.18 MByte/s (±8727.27 MByte/s) 1.02
Memset speed - (built_in) block size 1048576 1003.56 MByte/s (±4817.10 MByte/s) 998.03 MByte/s (±4790.54 MByte/s) 1.01
Memset speed - (built_in) block size 16777216 969.86 MByte/s (±4655.34 MByte/s) 969.61 MByte/s (±4654.13 MByte/s) 1.00
Memcpy speed - (rust) block size 4096 1379.31 MByte/s (±6620.69 MByte/s) 1395.35 MByte/s (±6697.67 MByte/s) 0.99
Memcpy speed - (rust) block size 1048576 736.17 MByte/s (±3533.63 MByte/s) 760.62 MByte/s (±3650.95 MByte/s) 0.97
Memcpy speed - (rust) block size 16777216 220.62 MByte/s (±1058.96 MByte/s) 207.47 MByte/s (±995.86 MByte/s) 1.06
Memset speed - (rust) block size 4096 1818.18 MByte/s (±8727.27 MByte/s) 1558.44 MByte/s (±7480.52 MByte/s) 1.17
Memset speed - (rust) block size 1048576 990.15 MByte/s (±4752.71 MByte/s) 966.16 MByte/s (±4637.57 MByte/s) 1.02
Memset speed - (rust) block size 16777216 760.29 MByte/s (±3649.40 MByte/s) 906.89 MByte/s (±4353.08 MByte/s) 0.84
alloc_benchmarks Build Time 86.01 s 97.22 s 0.88
alloc_benchmarks File Size 0.97 MB 0.97 MB 1.00
Allocations - Allocation success 2.00 % (±13.86 %) 2.00 % (±13.86 %) 1
Allocations - Deallocation success 1.41 % (±9.74 %) 1.40 % (±9.68 %) 1.01
Allocations - Pre-fail Allocations 2.00 % (±13.86 %) 2.00 % (±13.86 %) 1
Allocations - Average Allocation time 234.19 Ticks (±1622.89 Ticks) 256.15 Ticks (±1775.01 Ticks) 0.91
Allocations - Average Allocation time (no fail) 234.19 Ticks (±1622.89 Ticks) 256.15 Ticks (±1775.01 Ticks) 0.91
Allocations - Average Deallocation time 15.33 Ticks (±106.25 Ticks) 17.50 Ticks (±121.27 Ticks) 0.88
mutex_benchmark Build Time 85.74 s 94.97 s 0.90
mutex_benchmark File Size 1.01 MB 1.01 MB 1.00
Mutex Stress Test Average Time per Iteration - 1 Threads 0.26 ns (±1.80 ns) 0.32 ns (±2.22 ns) 0.81
Mutex Stress Test Average Time per Iteration - 2 Threads 0.32 ns (±2.22 ns) 0.38 ns (±2.63 ns) 0.84

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

@mkroening
Copy link
Member

edit: not sure what the failing test is nor why it fails...

Firecracker is a bit flaky on CI nowadays, unfortunately.

Copy link
Member

@mkroening mkroening left a comment

Choose a reason for hiding this comment

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

This looks good to me and I am personally fine with using ioctl for this.

@stlankes, @jounathaen, are you fine with us pivoting to ioctl for controlling drivers?

@mkroening mkroening requested review from stlankes and jounathaen July 28, 2025 14:43
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