add support for new timeout feature
v2 cover add support for new timeout feature
Kernel can handle timeout when feature IORING_FEAT_GETEVENTS_TIMEOUT supported. Applications should use io_uring_set_cqwait_timeout() explicitly to asked for the new feature.
Jiufei Xue (2):io_uring_enter: add timeout support test/timeout: add testcase for new timeout feature
PATCH v2 1/2 io_uring_enter: add timeout support
Kernel can handle timeout when feature IORING_FEAT_GETEVENTS_TIMEOUT supported. Applications should use io_uring_set_cqwait_timeout() explicitly to asked for the new feature.
In addition in this commit we add two new members to io_uring and a pad for future flexibility. So for the next release, applications have to re-compile against the lib.
--- src/include/liburing.h | 12 +++++- src/include/liburing/io_uring.h | 7 ++++ src/liburing.map | 2 + src/queue.c | 88 ++++++++++++++++++++++++++++++----------- src/setup.c | 1 + src/syscall.c | 4 +- src/syscall.h | 2 +- 7 files changed, 88 insertions(+), 28 deletions(-)
src/include/liburing.h +10 -2
@@ -56,6 +56,9 @@ struct io_uring {struct io_uring_sq sq;struct io_uring_cq cq;unsigned flags; +unsigned flags_internal; +unsigned features; +unsigned pad;int ring_fd; };
@@ -93,6 +96,7 @@ extern int io_uring_wait_cqes(struct io_uring *ring, struct __kernel_timespec *ts, sigset_t *sigmask);extern int io_uring_wait_cqe_timeout (struct io_uring *ring,struct io_uring_cqe **cqe_ptr,struct __kernel_timespec *ts); +extern int io_uring_set_cqwait_timeout (struct io_uring *ring);extern int io_uring_submit (struct io_uring *ring);extern int io_uring_submit_and_wait (struct io_uring *ring,unsigned wait_nr);extern struct io_uring_sqe *io_uring_get_sqe (struct io_uring *ring);
@@ -120,10 +124,14 @@ extern int io_uring_unregister_personality(struct io_uring *ring, int id);*/ extern int __io_uring_get_cqe (struct io_uring *ring,struct io_uring_cqe **cqe_ptr,unsigned submit, -unsigned wait_nr,sigset_t *sigmask); +unsigned wait_nr,struct __kernel_timespec *ts, +sigset_t *sigmask);#define LIBURING_UDATA_TIMEOUT ((__u64) -1) +/* io_uring->flags_internal */ +#define IORING_FLAGS_GETEVENTS_TIMEOUT (1U << 0)/* use the feature FEAT_GETEVENTS_TIMEOUT */ +#define io_uring_for_each_cqe (ring, head, cqe) \/* \ * io_uring_smp_load_acquire() enforces the order of tail \
@@ -491,7 +499,7 @@ static inline int io_uring_wait_cqe_nr(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, unsigned wait_nr) { -return __io_uring_get_cqe (ring, cqe_ptr,0 , wait_nr,NULL ); +return __io_uring_get_cqe (ring, cqe_ptr,0 , wait_nr,NULL ,NULL ); }/*
src/include/liburing/io_uring.h +7 -0
@@ -228,6 +228,7 @@ struct io_cqring_offsets {*/ #define IORING_ENTER_GETEVENTS (1U << 0)#define IORING_ENTER_SQ_WAKEUP (1U << 1) +#define IORING_ENTER_GETEVENTS_TIMEOUT (1U << 2)/* * Passed in for io_uring_setup(2). Copied back with updated info on success
@@ -255,6 +256,7 @@ struct io_uring_params {#define IORING_FEAT_CUR_PERSONALITY (1U << 4)#define IORING_FEAT_FAST_POLL (1U << 5)#define IORING_FEAT_POLL_32BITS (1U << 6) +#define IORING_FEAT_GETEVENTS_TIMEOUT (1U << 7)/* * io_uring_register(2) opcodes and arguments
@@ -294,6 +296,11 @@ struct io_uring_probe {struct io_uring_probe_op ops[0 ]; }; +struct io_uring_getevents_arg { +sigset_t *sigmask; +struct __kernel_timespec *ts; +}; + #ifdef __cplusplus }#endif
src/liburing.map +2 -0
@@ -56,4 +56,6 @@ LIBURING_0.6 { } LIBURING_0.5; LIBURING_0.7 { + global: + io_uring_set_cqwait_timeout; } LIBURING_0.6;
src/queue.c +65 -23
137 lines not on this page · raw message
src/setup.c +1 -0
@@ -96,6 +96,7 @@ int io_uring_queue_mmap(int fd, struct io_uring_params *p, struct io_uring *ringif (!ret) { ring->flags = p->flags; ring->ring_fd = fd; + ring->features = p->features; }return ret; }
src/syscall.c +2 -2
@@ -48,8 +48,8 @@ int __sys_io_uring_setup(unsigned entries, struct io_uring_params *p) }int __sys_io_uring_enter (int fd,unsigned to_submit,unsigned min_complete, -unsigned flags,sigset_t *sig) +unsigned flags,void *argp) {return syscall (__NR_io_uring_enter, fd, to_submit, min_complete, - flags, sig, _NSIG /8 ); + flags, argp, _NSIG /8 ); }
src/syscall.h +1 -1
@@ -7,7 +7,7 @@*/ extern int __sys_io_uring_setup (unsigned entries,struct io_uring_params *p);extern int __sys_io_uring_enter (int fd,unsigned to_submit, -unsigned min_complete,unsigned flags,sigset_t *sig); +unsigned min_complete,unsigned flags,void *argp);extern int __sys_io_uring_register (int fd,unsigned int opcode,const void *arg,unsigned int nr_args);
Signature · 1 line
1.8.3.1
Re: [PATCH liburing v2 1/2] io_uring_enter: add timeout support
Am 04.08.20 um 11:21 schrieb Jiufei Xue:
Quoted 7 lines
Kernel can handle timeout when feature
IORING_FEAT_GETEVENTS_TIMEOUTsupported. Applications should useio_uring_set_cqwait_timeout()explicitly to asked for the new feature.In addition in this commit we add two new members to
io_uringand a pad for future flexibility. So for the next release, applications have to re-compile against the lib.
I don't think this is an option, existing applications need to work.
Or they must fail at startup when the runtime dependencies are resolved. Which means the soname of the library has to change.
metze
Re: [PATCH liburing v2 1/2] io_uring_enter: add timeout support
Quoted 5 lines · Stefan Metzmacher
Am 04.08.20 um 11:21 schrieb Jiufei Xue:
Quoted 4 lines
Kernel can handle timeout when feature
IORING_FEAT_GETEVENTS_TIMEOUTsupported. Applications should useio_uring_set_cqwait_timeout()explicitly to asked for the new feature.
Quoted 9 lines
Quoted 3 lines
In addition in this commit we add two new members to
io_uringand a pad for future flexibility. So for the next release, applications have to re-compile against the lib.I don't think this is an option, existing applications need to work.
Or they must fail at startup when the runtime dependencies are resolved. Which means the soname of the library has to change.
Yes, I think the version should bump to 2.0.X with next release.
Jens,
should I bump the version with this patch set? Or you will bump it before next release.
Thanks,
Jiufei
Quoted 2 lines
metze
Jens Axboe
maintainerRe: [PATCH liburing v2 1/2] io_uring_enter: add timeout support
Quoted 18 lines · Jiufei Xue
Quoted 5 lines · Stefan Metzmacher
Am 04.08.20 um 11:21 schrieb Jiufei Xue:
Quoted 4 lines
Kernel can handle timeout when feature
IORING_FEAT_GETEVENTS_TIMEOUTsupported. Applications should useio_uring_set_cqwait_timeout()explicitly to asked for the new feature.Quoted 9 lines
Quoted 3 lines
In addition in this commit we add two new members to
io_uringand a pad for future flexibility. So for the next release, applications have to re-compile against the lib.I don't think this is an option, existing applications need to work.
Or they must fail at startup when the runtime dependencies are resolved. Which means the soname of the library has to change.
Quoted 5 lines
Yes, I think the version should bump to 2.0.X with next release.
Jens,
should I bump the version with this patch set? Or you will bump it before next release.
It should get bumped with the change, otherwise things will fail before the next release in case people run the git version.
And while you're at it, add some more pad. Don't want to go through the same process again the next time we need a bit of space. Just add 4 unsigneds as pad at least, that's enough for a pointer and 2 32-bit entries.
Signature · 1 line
Jens Axboe
Re: [PATCH liburing v2 1/2] io_uring_enter: add timeout support
Quoted 25 lines · Jens Axboe
Quoted 18 lines · Jiufei Xue
Quoted 5 lines · Stefan Metzmacher
Am 04.08.20 um 11:21 schrieb Jiufei Xue:
Quoted 4 lines
Kernel can handle timeout when feature
IORING_FEAT_GETEVENTS_TIMEOUTsupported. Applications should useio_uring_set_cqwait_timeout()explicitly to asked for the new feature.Quoted 9 lines
Quoted 3 lines
In addition in this commit we add two new members to
io_uringand a pad for future flexibility. So for the next release, applications have to re-compile against the lib.I don't think this is an option, existing applications need to work.
Or they must fail at startup when the runtime dependencies are resolved. Which means the soname of the library has to change.
Quoted 5 lines
Yes, I think the version should bump to 2.0.X with next release.
Jens,
should I bump the version with this patch set? Or you will bump it before next release.
Quoted 8 lines
It should get bumped with the change, otherwise things will fail before the next release in case people run the git version.
And while you're at it, add some more pad. Don't want to go through the same process again the next time we need a bit of space. Just add 4 unsigneds as pad at least, that's enough for a pointer and 2 32-bit entries.
ok. I will send version 3 later with these modification.
Thank,
Jiufei
PATCH v2 2/2 test/timeout: add testcase for new timeout feature
In reply to Jiufei Xue--- test/Makefile | 1 + test/timeout.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+)
test/Makefile +1 -0
@@ -89,6 +89,7 @@ submit-reuse: XCFLAGS = -lpthread poll-v-poll: XCFLAGS = -lpthread across-fork: XCFLAGS = -lpthread ce593a6c480a-test: XCFLAGS = -lpthread +timeout: XCFLAGS = -lpthread install: $(all_targets) runtests.sh runtests-loop.sh $(INSTALL) -D -d -m 755 $(datadir)/liburing-test/
test/timeout.c +97 -0
121 lines not on this page · raw message
Signature · 1 line
1.8.3.1