Skip to content

Commit

Permalink
io_uring: incremental provided buffer consumption
Browse files Browse the repository at this point in the history
[Incremental provided buffer
consumption](https://github.com/axboe/liburing/wiki/What's-new-with-io_uring-in-6.11-and-6.12#incremental-provided-buffer-consumption)
support is added in kernel 6.12.

IoUring.BufferGroup will now use incremental consumption whenever
kernel supports it.

Before, provided buffers are wholly consumed when picked. Each cqe
points to the different buffer. With this, cqe points to the part of the
buffer. Multiple cqe's can reuse same buffer.
Appropriate sizing of buffers becomes less important.

There are slight changes in BufferGroup interface (it now needs to track
current receive point for each buffer). Init requires allocator
instead of buffers slice, it will allocate buffers slice and head
pointers slice. Get and put now requires cqe becasue there we have
information will the buffer be reused.
  • Loading branch information
ianic committed Mar 3, 2025
1 parent a78d247 commit fdb6344
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 84 deletions.
9 changes: 8 additions & 1 deletion lib/std/os/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5933,6 +5933,8 @@ pub const IORING_CQE_F_MORE = 1 << 1;
pub const IORING_CQE_F_SOCK_NONEMPTY = 1 << 2;
/// Set for notification CQEs. Can be used to distinct them from sends.
pub const IORING_CQE_F_NOTIF = 1 << 3;
/// If set, the buffer ID set in the completion will get more completions.
pub const IORING_CQE_F_BUF_MORE = 1 << 4;

pub const IORING_CQE_BUFFER_SHIFT = 16;

Expand Down Expand Up @@ -6222,8 +6224,13 @@ pub const io_uring_buf_reg = extern struct {
ring_addr: u64,
ring_entries: u32,
bgid: u16,
pad: u16,
flags: u16,
resv: [3]u64,

pub const FLAG = struct {
// Incremental buffer consummation.
pub const INC: u16 = 2;
};
};

pub const io_uring_getevents_arg = extern struct {
Expand Down
Loading

0 comments on commit fdb6344

Please sign in to comment.