-
When we've added buffers and submitted them to the kernel and then request a read using IOSQE_BUFFER_SELECT, what is the algorithm that io_uring uses for selecting the buffer? Is it the most recently added buffer? If buffers are added dynamically, then won't this invalidate data in already used buffers? Or does it loop downwards until it finds a free buffer? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It'll just pick the first one. It's a very hot path, so no fancy selections are happening here. In general, regardless of whether this is ring provided buffers or the legacy ones, it'll be FIFO ordering. For ring provided buffers, that's the only way it can be done, and for legacy provided buffers, we just add to the tail when new buffers are provided.
Hmm? If the buffer is provided, it must be free to be used. When it's consumed, it's no longer in the pool, and has to be provided back. The application should not do that before it's finished with the data, obviously.
By definition, all the buffers provided are free. I think you misunderstand how provided buffers work. You provide a buffer, that one is know owned by the kernel. You submit a request that will consume it at some point. Once consumed, it's no longer in the provided buffer pool and the application now owns it. The application will do what it needs to with the data, and if it wishes, it can put it back in the provided buffer pool. That will then again transfer ownership to the kernel, and the cycle can continue. |
Beta Was this translation helpful? Give feedback.
It'll just pick the first one. It's a very hot path, so no fancy selections are happening here. In general, regardless of whether this is ring provided buffers or the legacy ones, it'll be FIFO ordering. For ring provided buffers, that's the only way it can be done, and for legacy provided buffers, we just add to the tail when new buffers are provided.
Hmm? If the buffer is provided, it must be free to be used. When it's consumed, it's no longer in the pool, and has to be provided back. The application should not do that before it's finished with the data, obviously.