Skip to content

feat: add generic ioctl support #1819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

zyuiop
Copy link

@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
Copy link
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: d4b9e27 Previous: 916c0d1 Performance Ratio
startup_benchmark Build Time 99.97 s 99.64 s 1.00
startup_benchmark File Size 0.87 MB 0.87 MB 1.00
Startup Time - 1 core 0.87 s (±0.02 s) 0.91 s (±0.02 s) 0.95
Startup Time - 2 cores 0.88 s (±0.02 s) 0.91 s (±0.01 s) 0.98
Startup Time - 4 cores 0.92 s (±0.01 s) 0.92 s (±0.02 s) 0.99
multithreaded_benchmark Build Time 100.61 s 100.90 s 1.00
multithreaded_benchmark File Size 0.98 MB 0.97 MB 1.00
Multithreaded Pi Efficiency - 2 Threads 70.48 % (±6.20 %) 72.02 % (±3.89 %) 0.98
Multithreaded Pi Efficiency - 4 Threads 40.92 % (±3.00 %) 42.13 % (±3.21 %) 0.97
Multithreaded Pi Efficiency - 8 Threads 20.56 % (±1.58 %) 20.62 % (±1.67 %) 1.00
micro_benchmarks Build Time 101.45 s 82.66 s 1.23
micro_benchmarks File Size 0.98 MB 0.98 MB 1.00
Scheduling time - 1 thread 62.41 ticks (±2.41 ticks) 50.76 ticks (±1.58 ticks) 1.23
Scheduling time - 2 threads 36.62 ticks (±5.19 ticks) 29.97 ticks (±4.74 ticks) 1.22
Micro - Time for syscall (getpid) 15.40 ticks (±1.00 ticks) 13.62 ticks (±1.90 ticks) 1.13
Memcpy speed - (built_in) block size 4096 74405.99 MByte/s (±51429.56 MByte/s) 87836.97 MByte/s (±60687.62 MByte/s) 0.85
Memcpy speed - (built_in) block size 1048576 41062.80 MByte/s (±28526.47 MByte/s) 44377.25 MByte/s (±30655.67 MByte/s) 0.93
Memcpy speed - (built_in) block size 16777216 27658.77 MByte/s (±22734.88 MByte/s) 30073.21 MByte/s (±24686.15 MByte/s) 0.92
Memset speed - (built_in) block size 4096 74437.91 MByte/s (±51451.96 MByte/s) 87609.46 MByte/s (±60567.75 MByte/s) 0.85
Memset speed - (built_in) block size 1048576 41335.28 MByte/s (±28706.01 MByte/s) 44601.88 MByte/s (±30809.54 MByte/s) 0.93
Memset speed - (built_in) block size 16777216 28360.50 MByte/s (±23131.50 MByte/s) 30861.29 MByte/s (±25146.75 MByte/s) 0.92
Memcpy speed - (rust) block size 4096 66090.73 MByte/s (±46089.79 MByte/s) 78085.94 MByte/s (±54382.07 MByte/s) 0.85
Memcpy speed - (rust) block size 1048576 40986.27 MByte/s (±28454.73 MByte/s) 44176.28 MByte/s (±30556.63 MByte/s) 0.93
Memcpy speed - (rust) block size 16777216 27703.27 MByte/s (±22775.27 MByte/s) 30071.23 MByte/s (±24675.89 MByte/s) 0.92
Memset speed - (rust) block size 4096 66139.99 MByte/s (±46124.47 MByte/s) 78452.24 MByte/s (±54650.22 MByte/s) 0.84
Memset speed - (rust) block size 1048576 41221.03 MByte/s (±28612.55 MByte/s) 44416.03 MByte/s (±30723.13 MByte/s) 0.93
Memset speed - (rust) block size 16777216 28422.92 MByte/s (±23189.38 MByte/s) 30862.88 MByte/s (±25137.48 MByte/s) 0.92
alloc_benchmarks Build Time 93.62 s 79.90 s 1.17
alloc_benchmarks File Size 0.93 MB 0.94 MB 1.00
Allocations - Allocation success 100.00 % 100.00 % 1
Allocations - Deallocation success 70.04 % (±0.26 %) 69.94 % (±0.25 %) 1.00
Allocations - Pre-fail Allocations 100.00 % 100.00 % 1
Allocations - Average Allocation time 10901.61 Ticks (±1053.99 Ticks) 10148.44 Ticks (±733.14 Ticks) 1.07
Allocations - Average Allocation time (no fail) 10901.61 Ticks (±1053.99 Ticks) 10148.44 Ticks (±733.14 Ticks) 1.07
Allocations - Average Deallocation time 746.65 Ticks (±86.89 Ticks) 662.38 Ticks (±35.19 Ticks) 1.13
mutex_benchmark Build Time 94.46 s 80.36 s 1.18
mutex_benchmark File Size 0.98 MB 0.98 MB 1.00
Mutex Stress Test Average Time per Iteration - 1 Threads 14.10 ns (±0.64 ns) 11.50 ns (±0.50 ns) 1.23
Mutex Stress Test Average Time per Iteration - 2 Threads 17.76 ns (±1.82 ns) 12.88 ns (±0.71 ns) 1.38

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