Function io_uring

Source
pub fn io_uring()
Expand description

§io_uring 异步 I/O 模型

Linux AIO 实现的并不理想,所以引入了新的异步I/O接口 io_uring。

+----+ Head  +---------+               +----------+ Head
|            |         |               |          |
|            |         |               |          |
|            +---------+               +----------+
|            |         |               |          |
|            |         |               |          |
|            +---------+               +----------+
|            |         |               |          |
|            |         |               |          |
|            +---------+               +----------+
|            |         |               |          |
|      Tail  +---------+               +----------+ Tail <--+
|        +--------------------------------------------+     |
|        | Kernel                                     |     |
|        |                                            |     |
|        |        +-------+              +-------+    |     |
|        |        |       |              |       |    |     |
+---------------> | SQ    |              |  CQ   | +--------+
         |        |       |              |       |    |
         |        +-------+              +-------+    |
         |                                            |
         +--------------------------------------------+

io_uring接口通过两个主要数据结构工作:

  • 提交队列条目(sqe)
  • 完成队列条目(cqe)

这些结构的实例位于内核和应用程序之间的共享内存单生产者单消费者环形缓冲区中。

参考:

https://thenewstack.io/how-io_uring-and-ebpf-will-revolutionize-programming-in-linux/

https://cor3ntin.github.io/posts/iouring/#io_uring