IoUring: use typed Flags and start syncing with liburing 2.12#25394
IoUring: use typed Flags and start syncing with liburing 2.12#25394bernardassan wants to merge 41 commits intoziglang:masterfrom
Conversation
That seems like a regression? Why is that desirable? |
|
Why is it a regression? It makes |
|
Now have IoUring and Linux test tests passing ❯ zig test lib/std/std.zig --zig-lib-dir lib --test-filter "os.linux"
68/116 os.linux.test.test.futex2_wait...SKIP
69/116 os.linux.test.test.futex2_wake...SKIP
70/116 os.linux.test.test.futex2_requeue...SKIP
111/116 os.linux.IoUring.test.waitid...SKIP
116/116 os.linux.IoUring.test.bind/listen/connect...SKIP
111 passed; 5 skipped; 0 failed.Full test suite also passes ❯ zig test lib/std/std.zig --zig-lib-dir lib
441/2932 debug.test.manage resources correctly...SKIP
1163/2932 crypto.25519.x25519.test.rfc7748 1,000 iterations...SKIP
1164/2932 crypto.25519.x25519.test.rfc7748 1,000,000 iterations...SKIP
1288/2932 crypto.scrypt.test.kdf...SKIP
1289/2932 crypto.scrypt.test.kdf rfc 1...SKIP
1290/2932 crypto.scrypt.test.kdf rfc 2...SKIP
1291/2932 crypto.scrypt.test.kdf rfc 3...SKIP
1292/2932 crypto.scrypt.test.kdf rfc 4...SKIP
1293/2932 crypto.scrypt.test.password hashing (crypt format)...SKIP
1294/2932 crypto.scrypt.test.strHash and strVerify...SKIP
1295/2932 crypto.scrypt.test.unix-scrypt...SKIP
1301/2932 crypto.pbkdf2.test.RFC 6070 16,777,216 iterations...SKIP
1304/2932 crypto.pbkdf2.test.Very large dk_len...SKIP
1408/2932 fs.test.test.delete a setAsCwd directory on Windows...SKIP
1409/2932 fs.test.test.invalid UTF-8/WTF-8 paths...SKIP
1832/2932 net.test.test.non-blocking tcp server...SKIP
1833/2932 posix.test.test.WTF-8 to WTF-16 conversion buffer overflows...SKIP
1837/2932 posix.test.test.readlink on Windows...SKIP
1861/2932 posix.test.test.POSIX file locking with fcntl...SKIP
1941/2932 os.linux.test.test.futex2_wait...SKIP
1942/2932 os.linux.test.test.futex2_wake...SKIP
1943/2932 os.linux.test.test.futex2_requeue...SKIP
1945/2932 os.windows.nls.test.upcaseW matches RtlUpcaseUnicodeChar...SKIP
2269/2932 json.static_test.test.test all types...SKIP
2305/2932 json.dynamic_test.test.polymorphic parsing...SKIP
2363/2932 os.linux.IoUring.test.waitid...SKIP
2368/2932 os.linux.IoUring.test.bind/listen/connect...SKIP
2905 passed; 27 skipped; 0 failed.
4 fuzz tests found. |
956b5a1 to
dbd89a6
Compare
|
There currently does not seem to be a replacement for int_flags on the ring. liburing uses that to set NO_IOWAIT flag to then before doing enter in for example submit_and_wait instead of initializing flags as 0 it is instead set to a mask of int_flags which includes NO_IOWAIT. and: otherwise I like these changes since they add type safety around the flags. While playing with this I found the bug in my own PR. |
|
This is on my to-do list, but I wanted to first get But because this is affecting a real-world projects ghostty which I use 😄 , let me add the |
c43fdb4 to
0768827
Compare
0768827 to
53b2359
Compare
|
Thanks, I will take a look. Im fine without being co authored, but if you insist then you can just use my public github email (45874591+RaidoAun@users.noreply.github.com). It should also be visible on the commit on my PR. |
53b2359 to
5785357
Compare
5785357 to
dba0c81
Compare
There was a problem hiding this comment.
The code regarding NO_IOWAIT looks fine now. If I find time to experiment with io_uring then I will try to test more of this branch. This branch has gotten quite big and I think you should try to get a core team members opinions on this. I would really like to see these changes get merged.
If you need help with this then I am willing to also contribute.
|
That is true, I didn't expect it to get this big, but I guess because we are way behind I agree it's a good time to start getting reviews from core team members and previous contributors, as there are only a few more operations I want to implement and leave the rest as future enhancements, which I would make another PR for. |
|
On my Arch Linux machine ❯ zig test lib/std/std.zig --zig-lib-dir lib --test-filter "os.linux" |
e0f8ccb to
321a739
Compare
3e2196f to
7b43abb
Compare
|
Finally done with all planned work for this PR. I would appreciate reviews and feedback from core maintainers, previous maintainers, and anyone interested in this changeset. All tests are passing, and I'm able to build a debug build of Zig on this branch. |
5eac1b0 to
b0dcde4
Compare
|
@Vexu @alexrp I have fixed the build error.
I have been trying to port the self-hosted CI to GitHub runners so I can test PRs in my branch before upstreaming them. Mac and Windows have Zig hosted deps, which makes the process very easy, but I tried the Linux one, and there doesn't seem to be a Linux variant of the hosted deps. It seems to be preinstalled on the self-hosted CI. Is there a way I can get a copy of these deps? |
update io_uring_enter and io_uring_register syscalls to use IoUring flags and types Cleanup comments Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
now that IoUring.zig is self contained Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
add Deprecated linux.W fns Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
update `cq_ring_needs_flush()` to match liburing replace FilesUpdate with RsrcUpdate struct Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Future enhancement: enter_ring_fd: u24, init_flags: u8, register functions that require the extra fields above like io_uring_register_ring_fd, io_uring_close_ring_fd, io_uring_clone_buffers_offset, io_uring_set_iowait not implemented register_*_tag functions not implemented remove unnecessary use of @ptrCast in io_uring_register Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
add IoUring tee syscall functionality adapt ReadBuffer union idea for read_fixed to support fixed read and readv Use same idea and create a WriteBuffer type for write() and write_fixed() ignored flags for splice and tee lets see if they become important in the future add a get_data helper to Cqe Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Add timeout update, cancel_fd, epoll_wait, files_update, open, open_direct, f/madvice don't implement f/madvice64 for now I doubt it is used by a lot of people in practice Implement BufferGroup read_multishot Try to make definition of function align as logically as posible with liburing to make keeping our implementation in sync easy TODO: add M/Fadvice enum flags TODO: understand buffer_selection and how its different from BufferGroup Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
ignore prep_openat2* for now add non-at variant of some unlink, rename, mkdir, symlink, link TODO: add Sync File Flags Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
TODO: add SetXattr flags Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
closes ziglang#25566 closes ziglang#25604 and IoUring enter_flags() helper function add typed Init flags which match int_flags in liburing Co-authored-by: RaidoAun <45874591+RaidoAun@users.noreply.github.com> Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com> Add futex_* operations to IoUring Refactor Futex 2 flags into Futex2 struct add mpol to Wait flags and fix private field as its 128 not 32 Signed-off-by: Bernard Assan <mega.alpha100@gmail.com> Update futex2_* functions and constants to use the new Futex2 type Improve the Api of futex2_* functions to be more idiomatic Zig Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Cleanup linux/test.zig type futex/2_* uaddr as *const u32 consider changing to *const atomic.Value(u32) Use At Flags in fstatat Use EpollOp in epoll_ctl syscall Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Build on the extensive work already done IoUring: add fixed_fd_install, ftruncate, cmd_discard Working on IoUring pipe flags Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Add dedicated Pipe2 flags for pipe2 as O contains some fields which are invalid in that context Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Use explicit array types were possible Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Add SYNC_FILE_RANGE_* flags add XATTR_* flags Add Madvise for MADV_* constants Add Fadvise enum type for POSIX_FADV_* constants Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
Use appropriately sized integers where applicable Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
backout from updating `pipe2` syscall to use Pipe2 flags Review if useful to implement - openat2*, f/madvice64 Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
use flags in Threaded change futex signature to expect *const atomic.Value(u32) fix IoUring timeout test Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
The fix got reverted in the merge conflict but now properly fix `At` Update posix `At` to use packed struct (I was holding back from touching `posix` and `c` but I might as well just get this done instead of using the deprecated constants since the diff is already big and At is worth while) Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
fixes the below on CI /lib/std/process/Child.zig:526:24: error: cannot @bitcast to 'c.W__struct_316926'; struct does not have a guaranteed in-memory layout const w: posix.W = @bitcast(status); ^~~~~~~~~~~~~~~~ /lib/std/c.zig:3682:75: note: struct declared here .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => struct { ^~~~~~ Signed-off-by: Bernard Assan <mega.alpha100@gmail.com>
fc72d97 to
1240ace
Compare
IoUring Overhaul
IoUringio_uring_sqe.zigintoIoUringIoUringTypes, Constants, and Operationsinitfn withFlags.SetupIncompatible Flags References
SQPOLLcan't be used in conjunction withCOOP_TASKRUNaxboe/liburing#1075 (comment)examples/io_uring-udp.c: IORING_SETUP_COOP_TASKRUN is incompatible with (IORING_SETUP_SQPOLL | IORING_SETUP_SQ_AFF)? axboe/liburing#811 (comment)
https://nick-black.com/dankwiki/index.php/Io_uring
init_paramsfnlinux.zigint_flagsto fix a real-world issue in ghostty std.os.Linux.IoUring: add IORING_ENTER_NO_IOWAIT flag support #25566linux/test.zigandIoUringtestsFuture Enhancement
int_flagsandenter_ring_fd