Skip to content

Commit

Permalink
Update registered wait registration API
Browse files Browse the repository at this point in the history
Wrap it in a struct io_uring_cqwait_reg_arg, to allow for future
expansion more easily. If someone were to add a different struct
type to register, for example to include a full signal mask, then
that would then be possible.

Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
axboe committed Oct 28, 2024
1 parent da25bcd commit 2eb8f5d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/include/liburing.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ int io_uring_submit_and_wait_reg(struct io_uring *ring,
int arg_index);

int io_uring_register_cqwait_reg(struct io_uring *ring,
struct io_uring_reg_wait *arg, int nr);
struct io_uring_reg_wait *reg, int nr);
int io_uring_resize_rings(struct io_uring *ring, struct io_uring_params *p);
int io_uring_clone_buffers(struct io_uring *dst, struct io_uring *src);
int io_uring_register_buffers(struct io_uring *ring, const struct iovec *iovecs,
Expand Down
23 changes: 23 additions & 0 deletions src/include/liburing/io_uring.h
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,26 @@ enum {
IORING_REG_WAIT_TS = (1U << 0),
};

/*
* Argument for IORING_REGISTER_CQWAIT_REG, registering a region of
* struct io_uring_reg_wait that can be indexed when io_uring_enter(2) is
* called rather than pass in a wait argument structure separately.
*/
struct io_uring_cqwait_reg_arg {
__u32 flags;
__u32 struct_size;
__u32 nr_entries;
__u32 pad;
__u64 user_addr;
__u64 pad2[3];
};

/*
* Argument for io_uring_enter(2) with
* IORING_GETEVENTS | IORING_ENTER_EXT_ARG_REG set, where the actual argument
* is an index into a previously registered fixed wait region described by
* the below structure.
*/
struct io_uring_reg_wait {
struct __kernel_timespec ts;
__u32 min_wait_usec;
Expand All @@ -814,6 +834,9 @@ struct io_uring_reg_wait {
__u64 pad2[2];
};

/*
* Argument for io_uring_enter(2) with IORING_GETEVENTS | IORING_ENTER_EXT_ARG
*/
struct io_uring_getevents_arg {
__u64 sigmask;
__u32 sigmask_sz;
Expand Down
11 changes: 9 additions & 2 deletions src/register.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,14 @@ int io_uring_resize_rings(struct io_uring *ring, struct io_uring_params *p)
}

int io_uring_register_cqwait_reg(struct io_uring *ring,
struct io_uring_reg_wait *arg, int nr)
struct io_uring_reg_wait *reg, int nr)
{
return do_register(ring, IORING_REGISTER_CQWAIT_REG, arg, nr);
struct io_uring_cqwait_reg_arg arg = {
.flags = 0,
.struct_size = sizeof(*reg),
.nr_entries = nr,
.user_addr = (unsigned long) (uintptr_t) reg,
};

return do_register(ring, IORING_REGISTER_CQWAIT_REG, &arg, 1);
}

0 comments on commit 2eb8f5d

Please sign in to comment.