feat: add generic ioctl support - #1819
Conversation
5b8f40e to
fa34f51
Compare
| #[derive(Copy, Clone)] | ||
| pub struct IoCtlCall(pub u32); |
There was a problem hiding this comment.
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.
0922143 to
d4b9e27
Compare
|
@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... |
There was a problem hiding this comment.
Benchmark Results
Details
| Benchmark | Current: a8acdca | Previous: 2e23902 | Performance Ratio |
|---|---|---|---|
| startup_benchmark Build Time | 94.07 s |
80.34 s |
1.17 ❗ |
| startup_benchmark File Size | 0.78 MB |
0.80 MB |
0.98 ❗ |
| Startup Time - 1 core | 0.76 s (±0.01 s) |
0.75 s (±0.02 s) |
1.02 |
| Startup Time - 2 cores | 0.76 s (±0.01 s) |
0.74 s (±0.02 s) |
1.03 ❗ |
| Startup Time - 4 cores | 0.77 s (±0.02 s) |
0.74 s (±0.02 s) |
1.03 |
| multithreaded_benchmark Build Time | 93.81 s |
82.11 s |
1.14 ❗ |
| multithreaded_benchmark File Size | 0.87 MB |
0.86 MB |
1.02 ❗ |
| Multithreaded Pi Efficiency - 2 Threads | 66.58 % (±5.34 %) |
85.89 % (±6.61 %) |
0.78 ❗ |
| Multithreaded Pi Efficiency - 4 Threads | 40.07 % (±2.83 %) |
43.43 % (±2.56 %) |
0.92 |
| Multithreaded Pi Efficiency - 8 Threads | 19.63 % (±1.09 %) |
25.76 % (±1.53 %) |
0.76 ❗ |
| micro_benchmarks Build Time | 221.48 s |
80.40 s |
2.75 ❗ |
| micro_benchmarks File Size | 0.87 MB |
0.86 MB |
1.01 ❗ |
| Scheduling time - 1 thread | 179.75 ticks (±31.06 ticks) |
62.65 ticks (±4.06 ticks) |
2.87 ❗ |
| Scheduling time - 2 threads | 109.96 ticks (±25.41 ticks) |
34.08 ticks (±4.10 ticks) |
3.23 ❗ |
| Micro - Time for syscall (getpid) | 11.17 ticks (±5.54 ticks) |
3.45 ticks (±0.58 ticks) |
3.24 ❗ |
| Memcpy speed - (built_in) block size 4096 | 57557.90 MByte/s (±41154.11 MByte/s) |
82448.38 MByte/s (±56997.13 MByte/s) |
0.70 |
| Memcpy speed - (built_in) block size 1048576 | 14971.11 MByte/s (±12501.57 MByte/s) |
30585.98 MByte/s (±24707.84 MByte/s) |
0.49 |
| Memcpy speed - (built_in) block size 16777216 | 12451.95 MByte/s (±10357.72 MByte/s) |
26340.06 MByte/s (±21720.96 MByte/s) |
0.47 |
| Memset speed - (built_in) block size 4096 | 57856.26 MByte/s (±41392.11 MByte/s) |
82292.76 MByte/s (±56891.50 MByte/s) |
0.70 |
| Memset speed - (built_in) block size 1048576 | 15477.44 MByte/s (±12813.51 MByte/s) |
31323.85 MByte/s (±25145.86 MByte/s) |
0.49 |
| Memset speed - (built_in) block size 16777216 | 12863.83 MByte/s (±10633.52 MByte/s) |
27104.68 MByte/s (±22209.94 MByte/s) |
0.47 |
| Memcpy speed - (rust) block size 4096 | 55364.83 MByte/s (±39372.33 MByte/s) |
74097.96 MByte/s (±51811.44 MByte/s) |
0.75 |
| Memcpy speed - (rust) block size 1048576 | 15894.76 MByte/s (±14336.71 MByte/s) |
30361.60 MByte/s (±24602.37 MByte/s) |
0.52 |
| Memcpy speed - (rust) block size 16777216 | 13139.34 MByte/s (±11364.41 MByte/s) |
27625.34 MByte/s (±22806.88 MByte/s) |
0.48 |
| Memset speed - (rust) block size 4096 | 55707.39 MByte/s (±39578.86 MByte/s) |
74373.47 MByte/s (±51976.48 MByte/s) |
0.75 |
| Memset speed - (rust) block size 1048576 | 16143.41 MByte/s (±14437.08 MByte/s) |
31110.89 MByte/s (±25033.24 MByte/s) |
0.52 |
| Memset speed - (rust) block size 16777216 | 13427.19 MByte/s (±11501.35 MByte/s) |
28386.93 MByte/s (±23265.03 MByte/s) |
0.47 |
| alloc_benchmarks Build Time | 217.95 s |
74.76 s |
2.92 ❗ |
| alloc_benchmarks File Size | 0.86 MB |
0.87 MB |
0.98 ❗ |
| Allocations - Allocation success | 91.38 % |
91.31 % |
1.00 ❗ |
| Allocations - Deallocation success | 100.00 % |
100.00 % |
1 |
| Allocations - Pre-fail Allocations | 61.60 % |
61.44 % |
1.00 ❗ |
| Allocations - Average Allocation time | 24291.22 Ticks (±1619.55 Ticks) |
5860.58 Ticks (±98.43 Ticks) |
4.14 ❗ |
| Allocations - Average Allocation time (no fail) | 25162.60 Ticks (±1608.31 Ticks) |
6554.81 Ticks (±92.86 Ticks) |
3.84 ❗ |
| Allocations - Average Deallocation time | 7248.86 Ticks (±1812.81 Ticks) |
1805.01 Ticks (±250.35 Ticks) |
4.02 ❗ |
| mutex_benchmark Build Time | 212.09 s |
79.82 s |
2.66 ❗ |
| mutex_benchmark File Size | 0.87 MB |
0.86 MB |
1.02 ❗ |
| Mutex Stress Test Average Time per Iteration - 1 Threads | 34.48 ns (±7.52 ns) |
12.10 ns (±0.41 ns) |
2.85 ❗ |
| Mutex Stress Test Average Time per Iteration - 2 Threads | 31.20 ns (±8.66 ns) |
40.26 ns (±1.68 ns) |
0.77 ❗ |
This comment was automatically generated by workflow using github-action-benchmark.
Firecracker is a bit flaky on CI nowadays, unfortunately. |
mkroening
left a comment
There was a problem hiding this comment.
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?
|
I'm not a fan of "pivoting to ioctl for controlling drivers", but we can merge it for enhanced compatibility. I'd like to see a feature flag for ioctls, but this can be added later once we have researched the impacts of this. (We should create an issue for this) |
| pub unsafe extern "C" fn sys_ioctl( | ||
| fd: FileDescriptor, | ||
| cmd: i32, | ||
| cmd: c_ulong, |
There was a problem hiding this comment.
Check if we can remove this change to preserve the ABI
|
I have rebased the PR, in case there is still some interest for this! |
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.