axboe / liburing

Library providing helpers for the Linux kernel io_uring support
MIT License
2.72k stars 393 forks source link

Export __io_uring_flush_sq()? #1111

Open geertj opened 4 months ago

geertj commented 4 months ago

I realize that the recommended way to use io_uring is to have one ring per thread. Unfortunately this is not something that we can easily do in our application architecture. Instead, we'd like multiple threads to submit to the same ring. The most straightforward way to do this is to have separate submission and a completion threads. Users that want to do IO submit to a queue that's monitored by the submission thread, which prepares the IOs and submits them to the ring. The completion thread waits for CQEs and calls associated callbacks.

I was trying to come up with a way to not have a submission thread, but allow users to directly submit to a ring. This would save the time to wake up the submission thread. Ideally, the code that I'd like to write is this:

In low contention situations a requestor can start the IO right away. In higher contention situations, it should be no worse than having a separate thread. We also get automatic batching.

Would this be a good use case and justification to add io_uring_flush_sq() to the liburing public interface?

geertj commented 2 months ago

@axboe kind ping

isilence commented 2 months ago

You can add a new function to liburing without side effects of io_uring_flush_sq(), but why not count it in the userspace instead? you're locked anyway