Closed psarkar24 closed 9 months ago
If each thread is using its own ring, no there should not be any multi threading issues that you need to be aware of. The kernel side is always fine, it's just on the liburing side. But again, with separate rings, not really a concern.
Do you have a reproducer for this? I don't think it's a threading issue, but it could be a bug in the 5.15-stable kernel, potentially.
I'll work on creating a reproducer and attach to this issue.
Unless I misunderstand something, OP's code doesn't reap completions correctly, as it only waits for min_num_requests to complete.
However, this doesn't explain why request 2951741440 is not reaped the next time io_uring_wait_cqe() is called.
Unless I misunderstand something, OP's code doesn't reap completions correctly, as it only waits for min_num_requests to complete.
Could you please clarify your concern? The intent is to wait for min_num_requests
only and anything beyond is speculative using io_uring_peek_cqe
. Is the call to io_uring_peek_cqe
incorrect?
io_uring_peek_cqe() doesn't enter the kernel and only fetches the completions that were already added to the ring buffer by the last io_uring_wait_cqe().
Does you code work OK when you set min_num_requests to a very large number?
As written, your code should eventually overflow the CQ buffer, as you leave some completions behind with each iteration.
I have not provided the entire code (which was primarily presented to highlight threading issues ) but to give a summary of the test driver, max events = 8, num_requests = 8 and min_num_requests = 4. Reading a large file involves 1000s of requests and the test driver breaks them into chunks based on the parameters above.
The invariant is that the test driver keeps track and issues as many io_uring_wait_cqe requests as there are io_uring_submit requests. Also if any of the io_uring_peek_cqe requests are successful, then the number of io_uring_wait_cqe requests are deducted accordingly. I ljust finished a 100 GB read with 1 MB IO size and just 3 missing IOs. So based on the assertion that all requests are accounted for, and from experimental data, I don’t see how there could be a CQE overflow.
Hope this helps clarify your concerns.
Got it. What you describe is different from the snippets in your original message. Happy to look at your working example once you have it.
I'm unable to reproduce this outside of the environment where I am observing this. Will reopen this when I have more data, closing this issue for now.
I'm using 2.1-2build1 with Linux kernel 5.15.0. I have a program that is multi-threaded though in reality there are only two threads working at any given point in time.
Each thread has its own ring and does the following to initialize the ring:
Read I/O's are submitted using the following piece of code using param
num_requests
:I/O completions are tracked using the following piece of code using two params
num_requests
andmin_num_requests
:This works well for small files but for files >= 100 GB, an I/O goes missing every so often (once every 3000-10000 times). Here is an example where a read to offset
2951741440
is never responded to. In this run of the program, all invocations ofio_uring_peek_cqe
return-11
. The log parameters areoperation(ring_id, fd, offset, size)
Are there multi-threading issues I should be aware of. Even if threads have their own ring, is there any synchronization required? Could this be because of the underlying FS? Are there any debugging logs I can turn on?