diff --git a/1001-liburing-anolis-Add-percpu-io-sq-thread-support.patch b/1001-Add-percpu-io-sq-thread-support.patch similarity index 73% rename from 1001-liburing-anolis-Add-percpu-io-sq-thread-support.patch rename to 1001-Add-percpu-io-sq-thread-support.patch index 1ca7830e18c043f4bfca554000a34d95a91b19ef..149c071ea8304fea4875aac7b9e64f3df3cdf74d 100644 --- a/1001-liburing-anolis-Add-percpu-io-sq-thread-support.patch +++ b/1001-Add-percpu-io-sq-thread-support.patch @@ -1,7 +1,7 @@ -From c629576a5f266eedf2efbf74211581c68217d67c Mon Sep 17 00:00:00 2001 +From cd0ee5df307beda0cc8a14af09ffdaafcd5e0e6a Mon Sep 17 00:00:00 2001 From: Xiaoguang Wang Date: Thu, 6 Aug 2020 14:23:01 +0800 -Subject: [PATCH] Add percpu io sq thread support +Subject: [PATCH 1/4] Add percpu io sq thread support Add a new IORING_SETUP_SQPOLL_PERCPU flag, this flag is only meaningful when IORING_SETUP_SQPOLL and IORING_SETUP_SQ_AFF are both specified, that @@ -17,12 +17,12 @@ Acked-by: Joseph Qi 2 files changed, 11 insertions(+) diff --git a/man/io_uring_setup.2 b/man/io_uring_setup.2 -index d48bb32..3788084 100644 +index cd69994..30a2306 100644 --- a/man/io_uring_setup.2 +++ b/man/io_uring_setup.2 -@@ -131,6 +131,15 @@ This flag is only meaningful when - .B IORING_SETUP_SQPOLL - is specified. +@@ -147,6 +147,15 @@ is specified. When cgroup setting + changes (typically in container environment), the bounded cpu set may be + changed as well. .TP +.B IORING_SETUP_SQPOLL_PERCPU +This flag is only meaningful when @@ -37,18 +37,18 @@ index d48bb32..3788084 100644 Create the completion queue with .IR "struct io_uring_params.cq_entries" diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index 7843742..dbc3e4d 100644 +index a3e0920..d4a0d83 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h -@@ -94,6 +94,8 @@ enum { - #define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */ - #define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */ - #define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */ +@@ -166,6 +166,8 @@ enum { + * Only one task is allowed to submit requests + */ + #define IORING_SETUP_SINGLE_ISSUER (1U << 12) +/* use percpu SQ poll thread */ +#define IORING_SETUP_SQPOLL_PERCPU (1U << 31) - enum { - IORING_OP_NOP, + /* + * Defer running task work to get events. -- -2.17.2 +2.31.1 diff --git a/1002-liburing-anolis-Revert-Make-the-liburing-header-files-again-compatib.patch b/1002-liburing-anolis-Revert-Make-the-liburing-header-files-again-compatib.patch deleted file mode 100644 index a997e858a1688f4f3efff39ff8a67feff3be1c39..0000000000000000000000000000000000000000 --- a/1002-liburing-anolis-Revert-Make-the-liburing-header-files-again-compatib.patch +++ /dev/null @@ -1,127 +0,0 @@ -From d88bcf0e719c380d645d014984ec7e363163faa0 Mon Sep 17 00:00:00 2001 -From: Hao Xu -Date: Thu, 12 Nov 2020 19:22:12 +0800 -Subject: [PATCH 1/3] Revert "Make the liburing header files again compatible - with C++" - -This reverts commit 3d74c677c45eccf36b92f7ad4b3317adc1ed06bb. ---- - src/include/liburing.h | 8 ++++---- - src/include/liburing/barrier.h | 37 ++----------------------------------- - src/include/liburing/io_uring.h | 8 -------- - 3 files changed, 6 insertions(+), 47 deletions(-) - -diff --git a/src/include/liburing.h b/src/include/liburing.h -index 0505a4f50367..92e5018951d4 100644 ---- a/src/include/liburing.h -+++ b/src/include/liburing.h -@@ -2,6 +2,10 @@ - #ifndef LIB_URING_H - #define LIB_URING_H - -+#ifdef __cplusplus -+extern "C" { -+#endif -+ - #include - #include - #include -@@ -15,10 +19,6 @@ - #include "liburing/io_uring.h" - #include "liburing/barrier.h" - --#ifdef __cplusplus --extern "C" { --#endif -- - /* - * Library interface to io_uring - */ -diff --git a/src/include/liburing/barrier.h b/src/include/liburing/barrier.h -index a4a59fb499d6..57324348466b 100644 ---- a/src/include/liburing/barrier.h -+++ b/src/include/liburing/barrier.h -@@ -2,6 +2,8 @@ - #ifndef LIBURING_BARRIER_H - #define LIBURING_BARRIER_H - -+#include -+ - /* - From the kernel documentation file refcount-vs-atomic.rst: - -@@ -21,40 +23,6 @@ after the acquire operation executes. This is implemented using - :c:func:`smp_acquire__after_ctrl_dep`. - */ - --#ifdef __cplusplus --#include -- --template --static inline void IO_URING_WRITE_ONCE(T &var, T val) --{ -- std::atomic_store_explicit(reinterpret_cast *>(&var), -- val, std::memory_order_relaxed); --} --template --static inline T IO_URING_READ_ONCE(const T &var) --{ -- return std::atomic_load_explicit( -- reinterpret_cast *>(&var), -- std::memory_order_relaxed); --} -- --template --static inline void io_uring_smp_store_release(T *p, T v) --{ -- std::atomic_store_explicit(reinterpret_cast *>(p), v, -- std::memory_order_release); --} -- --template --static inline T io_uring_smp_load_acquire(const T *p) --{ -- return std::atomic_load_explicit( -- reinterpret_cast *>(p), -- std::memory_order_acquire); --} --#else --#include -- - #define IO_URING_WRITE_ONCE(var, val) \ - atomic_store_explicit((_Atomic typeof(var) *)&(var), \ - (val), memory_order_relaxed) -@@ -68,6 +36,5 @@ static inline T io_uring_smp_load_acquire(const T *p) - #define io_uring_smp_load_acquire(p) \ - atomic_load_explicit((_Atomic typeof(*(p)) *)(p), \ - memory_order_acquire) --#endif - - #endif /* defined(LIBURING_BARRIER_H) */ -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index d39b45fddb22..d65fde732518 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -11,10 +11,6 @@ - #include - #include - --#ifdef __cplusplus --extern "C" { --#endif -- - /* - * IO submission data structure (Submission Queue Entry) - */ -@@ -294,8 +290,4 @@ struct io_uring_probe { - struct io_uring_probe_op ops[0]; - }; - --#ifdef __cplusplus --} --#endif -- - #endif --- -1.8.3.1 - diff --git a/1016-liburing-anolis-support-us-granularity-of-io_sq_thread_idle.patch b/1002-support-us-granularity-of-io_sq_thread_idle.patch similarity index 61% rename from 1016-liburing-anolis-support-us-granularity-of-io_sq_thread_idle.patch rename to 1002-support-us-granularity-of-io_sq_thread_idle.patch index b55d0cc2eb840657308b57bdcc5f5abdfb19f2d6..6f6f85c6d0750ae4bae681a85ed9ca989f800eca 100644 --- a/1016-liburing-anolis-support-us-granularity-of-io_sq_thread_idle.patch +++ b/1002-support-us-granularity-of-io_sq_thread_idle.patch @@ -1,22 +1,22 @@ -From 65ac402fb0feb4ee74d71317f04c1b4422d78665 Mon Sep 17 00:00:00 2001 +From 5c31734118432639f7758d4671f1f05348914d63 Mon Sep 17 00:00:00 2001 From: Hao Xu Date: Mon, 10 May 2021 11:34:29 +0800 -Subject: [PATCH] support us granularity of io_sq_thread_idle +Subject: [PATCH 2/4] support us granularity of io_sq_thread_idle add flag IORING_SETUP_IDLE_US to support microsecond granularity io_sq_thread_idle. Signed-off-by: Hao Xu --- - man/io_uring_setup.2 | 9 ++++++++- + man/io_uring_setup.2 | 8 +++++++- src/include/liburing/io_uring.h | 1 + - 2 files changed, 9 insertions(+), 1 deletion(-) + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/man/io_uring_setup.2 b/man/io_uring_setup.2 -index 8c71e200d8b7..a2a9072423de 100644 +index 30a2306..082507c 100644 --- a/man/io_uring_setup.2 +++ b/man/io_uring_setup.2 -@@ -80,7 +80,9 @@ doing a single system call. +@@ -83,7 +83,9 @@ doing a single system call. If the kernel thread is idle for more than .I sq_thread_idle @@ -27,11 +27,10 @@ index 8c71e200d8b7..a2a9072423de 100644 .B IORING_SQ_NEED_WAKEUP bit in the .I flags -@@ -146,6 +148,11 @@ Create the completion queue with - entries. The value must be greater than - .IR entries , - and may be rounded up to the next power-of-two. -+.TP +@@ -287,6 +289,10 @@ Note that if this flag is set then it is the application's responsibility to per + trigger work (for example via any of the CQE waiting functions) or else completions may + not be delivered. + Available since 6.1. +.B IORING_SETUP_IDLE_US +If this flag is set, the unit of +.I sq_thread_idle @@ -40,17 +39,17 @@ index 8c71e200d8b7..a2a9072423de 100644 If no flags are specified, the io_uring instance is setup for interrupt driven I/O. I/O may be submitted using diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index 05d58cebcfcc..8b412fb21567 100644 +index d4a0d83..8291de7 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h -@@ -95,6 +95,7 @@ enum { - #define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */ - #define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */ - #define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */ +@@ -166,6 +166,7 @@ enum { + * Only one task is allowed to submit requests + */ + #define IORING_SETUP_SINGLE_ISSUER (1U << 12) +#define IORING_SETUP_IDLE_US (1U << 30) /* unit of thread_idle is microsecond */ /* use percpu SQ poll thread */ #define IORING_SETUP_SQPOLL_PERCPU (1U << 31) -- -1.8.3.1 +2.31.1 diff --git a/1017-liburing-anolis-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch b/1003-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch similarity index 46% rename from 1017-liburing-anolis-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch rename to 1003-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch index d0853d520efa115f378088b6e7bec9bf2fd0a461..3056111da9bb66468a6b6b49cbd95d4ad4758973 100644 --- a/1017-liburing-anolis-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch +++ b/1003-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch @@ -1,106 +1,97 @@ -From edc1b76b8d8a81b26e9a8399f91f73b066b112bf Mon Sep 17 00:00:00 2001 -From: Hao Xu -Date: Mon, 10 May 2021 14:39:02 +0800 -Subject: [PATCH] add IORING_ENTER_SQ_SUBMIT_ON_IDLE flag +From c6488e58ba2ba3b8a49e728143dac428b55f591a Mon Sep 17 00:00:00 2001 +From: Ziyang Zhang +Date: Thu, 1 Dec 2022 10:43:39 +0800 +Subject: [PATCH 3/4] add IORING_ENTER_SQ_SUBMIT_ON_IDLE flag add this flag to allow the original task to submit some sqes to reduce sqthread wakeup latency. Signed-off-by: Hao Xu +[Ziyang Zhang: adjust value of IORING_ENTER_SQ_SUBMIT_ON_IDLE] +Signed-off-by: Ziyang Zhang --- - debian/liburing1.symbols | 6 ++++++ src/include/liburing.h | 2 ++ src/include/liburing/io_uring.h | 1 + - src/liburing.map | 3 +++ - src/queue.c | 29 ++++++++++++++++++++++------- - 5 files changed, 34 insertions(+), 7 deletions(-) + src/liburing.map | 2 ++ + src/queue.c | 30 ++++++++++++++++++++++-------- + 4 files changed, 27 insertions(+), 8 deletions(-) -diff --git a/debian/liburing1.symbols b/debian/liburing1.symbols -index cc4d504895d3..dccce71d0e11 100644 ---- a/debian/liburing1.symbols -+++ b/debian/liburing1.symbols -@@ -26,3 +26,9 @@ liburing.so.1 liburing1 #MINVER# - io_uring_register_probe@LIBURING_0.4 0.4-1 - io_uring_ring_dontfork@LIBURING_0.4 0.4-1 - io_uring_unregister_personality@LIBURING_0.4 0.4-1 -+ (symver)LIBURING_0.5 0.5-1 -+ (symver)LIBURING_0.6 0.6-1 -+ (symver)LIBURING_0.7 0.7-8 -+ io_uring_submit_on_idle@LIBURING_0.7 0.7-8 -+ io_uring_submit_on_idle_and_wait@LIBURING_0.7 0.7-8 -+ diff --git a/src/include/liburing.h b/src/include/liburing.h -index 9fa5bc92986d..8a1dc7c6591f 100644 +index 12a703f..531bf2e 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h -@@ -97,7 +97,9 @@ extern int io_uring_wait_cqes(struct io_uring *ring, - 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_submit(struct io_uring *ring); -+extern int io_uring_submit_on_idle(struct io_uring *ring); - extern int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr); -+extern int io_uring_submit_on_idle_and_wait(struct io_uring *ring, unsigned wait_nr); - extern struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring); +@@ -176,12 +176,14 @@ int io_uring_wait_cqe_timeout(struct io_uring *ring, + struct io_uring_cqe **cqe_ptr, + struct __kernel_timespec *ts); + int io_uring_submit(struct io_uring *ring); ++int io_uring_submit_on_idle(struct io_uring *ring); + int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr); + int io_uring_submit_and_wait_timeout(struct io_uring *ring, + struct io_uring_cqe **cqe_ptr, + unsigned wait_nr, + struct __kernel_timespec *ts, + sigset_t *sigmask); ++int io_uring_submit_on_idle_and_wait(struct io_uring *ring, unsigned wait_nr); - extern int io_uring_register_buffers(struct io_uring *ring, + int io_uring_register_buffers(struct io_uring *ring, const struct iovec *iovecs, + unsigned nr_iovecs); diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index 8b412fb21567..cd1c68a753b9 100644 +index 8291de7..4b474e3 100644 --- a/src/include/liburing/io_uring.h +++ b/src/include/liburing/io_uring.h -@@ -229,6 +229,7 @@ struct io_cqring_offsets { - #define IORING_ENTER_GETEVENTS (1U << 0) - #define IORING_ENTER_SQ_WAKEUP (1U << 1) - #define IORING_ENTER_EXT_ARG (1U << 3) -+#define IORING_ENTER_SQ_SUBMIT_ON_IDLE (1U << 4) +@@ -423,6 +423,7 @@ struct io_cqring_offsets { + #define IORING_ENTER_SQ_WAIT (1U << 2) + #define IORING_ENTER_EXT_ARG (1U << 3) + #define IORING_ENTER_REGISTERED_RING (1U << 4) ++#define IORING_ENTER_SQ_SUBMIT_ON_IDLE (1U << 31) /* * Passed in for io_uring_setup(2). Copied back with updated info on success diff --git a/src/liburing.map b/src/liburing.map -index 38bd558a5a50..8c2ccfaca8c2 100644 +index 06c64f8..e8124a2 100644 --- a/src/liburing.map +++ b/src/liburing.map -@@ -56,4 +56,7 @@ LIBURING_0.6 { - } LIBURING_0.5; - - LIBURING_0.7 { -+ global: +@@ -66,4 +66,6 @@ LIBURING_2.3 { + io_uring_register; + io_uring_get_events; + io_uring_submit_and_get_events; + io_uring_submit_on_idle; + io_uring_submit_on_idle_and_wait; - } LIBURING_0.6; + } LIBURING_2.2; diff --git a/src/queue.c b/src/queue.c -index 2662e671fb34..d8ee64f25601 100644 +index c06bcc3..563c7c3 100644 --- a/src/queue.c +++ b/src/queue.c -@@ -304,12 +304,12 @@ int io_uring_wait_cqe_timeout(struct io_uring *ring, +@@ -366,13 +366,13 @@ int io_uring_wait_cqe_timeout(struct io_uring *ring, * Returns number of sqes submitted */ static int __io_uring_submit(struct io_uring *ring, unsigned submitted, -- unsigned wait_nr) -+ unsigned wait_nr, unsigned enter_flags) +- unsigned wait_nr, bool getevents) ++ unsigned wait_nr, bool getevents, unsigned enter_flags) { + bool cq_needs_enter = getevents || wait_nr || cq_ring_needs_enter(ring); - unsigned flags; + unsigned flags = 0; int ret; - flags = 0; + flags |= enter_flags; - if (sq_ring_needs_enter(ring, &flags) || wait_nr) { - if (wait_nr || (ring->flags & IORING_SETUP_IOPOLL)) + if (sq_ring_needs_enter(ring, submitted, &flags) || cq_needs_enter) { + if (cq_needs_enter) flags |= IORING_ENTER_GETEVENTS; -@@ -324,9 +324,10 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted, +@@ -387,9 +387,9 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted, return ret; } -static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr) +static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr, unsigned enter_flags) { -- return __io_uring_submit(ring, __io_uring_flush_sq(ring), wait_nr); -+ return __io_uring_submit(ring, __io_uring_flush_sq(ring), wait_nr, -+ enter_flags); +- return __io_uring_submit(ring, __io_uring_flush_sq(ring), wait_nr, false); ++ return __io_uring_submit(ring, __io_uring_flush_sq(ring), wait_nr, false, enter_flags); } /* -@@ -336,7 +337,16 @@ static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr) +@@ -399,7 +399,16 @@ static int __io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr) */ int io_uring_submit(struct io_uring *ring) { @@ -118,7 +109,7 @@ index 2662e671fb34..d8ee64f25601 100644 } /* -@@ -346,7 +356,12 @@ int io_uring_submit(struct io_uring *ring) +@@ -409,12 +418,17 @@ int io_uring_submit(struct io_uring *ring) */ int io_uring_submit_and_wait(struct io_uring *ring, unsigned wait_nr) { @@ -131,7 +122,13 @@ index 2662e671fb34..d8ee64f25601 100644 + return __io_uring_submit_and_wait(ring, wait_nr, IORING_ENTER_SQ_SUBMIT_ON_IDLE); } - static inline struct io_uring_sqe * + int io_uring_submit_and_get_events(struct io_uring *ring) + { +- return __io_uring_submit(ring, __io_uring_flush_sq(ring), 0, true); ++ return __io_uring_submit(ring, __io_uring_flush_sq(ring), 0, true, 0); + } + + #ifdef LIBURING_INTERNAL -- -1.8.3.1 +2.31.1 diff --git a/1003-liburing-anolis-Revert-src-include-liburing-barrier.h-Restore-clang-.patch b/1003-liburing-anolis-Revert-src-include-liburing-barrier.h-Restore-clang-.patch deleted file mode 100644 index 52053ac61ec62f649d9055c10d021b4d08b9a7cd..0000000000000000000000000000000000000000 --- a/1003-liburing-anolis-Revert-src-include-liburing-barrier.h-Restore-clang-.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0b51d4b2046f6c16179fbaff6c56c90c4985a0cb Mon Sep 17 00:00:00 2001 -From: Hao Xu -Date: Thu, 12 Nov 2020 19:25:50 +0800 -Subject: [PATCH 2/3] Revert "src/include/liburing/barrier.h: Restore clang - compatibility" - -This reverts commit 56ff6c964c5078d76cb3c2da1a62ad671749fd42. ---- - src/include/liburing/barrier.h | 12 ++++-------- - 1 file changed, 4 insertions(+), 8 deletions(-) - -diff --git a/src/include/liburing/barrier.h b/src/include/liburing/barrier.h -index 57324348466b..c8aa4210371c 100644 ---- a/src/include/liburing/barrier.h -+++ b/src/include/liburing/barrier.h -@@ -24,17 +24,13 @@ after the acquire operation executes. This is implemented using - */ - - #define IO_URING_WRITE_ONCE(var, val) \ -- atomic_store_explicit((_Atomic typeof(var) *)&(var), \ -- (val), memory_order_relaxed) -+ atomic_store_explicit(&(var), (val), memory_order_relaxed) - #define IO_URING_READ_ONCE(var) \ -- atomic_load_explicit((_Atomic typeof(var) *)&(var), \ -- memory_order_relaxed) -+ atomic_load_explicit(&(var), memory_order_relaxed) - - #define io_uring_smp_store_release(p, v) \ -- atomic_store_explicit((_Atomic typeof(*(p)) *)(p), (v), \ -- memory_order_release) -+ atomic_store_explicit((p), (v), memory_order_release) - #define io_uring_smp_load_acquire(p) \ -- atomic_load_explicit((_Atomic typeof(*(p)) *)(p), \ -- memory_order_acquire) -+ atomic_load_explicit((p), memory_order_acquire) - - #endif /* defined(LIBURING_BARRIER_H) */ --- -1.8.3.1 - diff --git a/1019-liburing-anolis-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch b/1004-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch similarity index 69% rename from 1019-liburing-anolis-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch rename to 1004-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch index 48ac945c6dfa89ce13b071be76f4eed8b2901c2b..0add38ee95770a1b523439633c542f1cd72b5b61 100644 --- a/1019-liburing-anolis-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch +++ b/1004-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch @@ -1,38 +1,28 @@ -From de26d9e8009058afef94d46b6a7c1751fadae894 Mon Sep 17 00:00:00 2001 +From fd1a90edb0c193db13f42cadeb588bc3d73ab18c Mon Sep 17 00:00:00 2001 From: Hao Xu -Date: Thu, 18 Nov 2021 15:51:54 +0800 -Subject: [PATCH 2/2] Add a test for sqpoll sq_thread_idle_us mode +Date: Tue, 6 Dec 2022 15:47:57 +0800 +Subject: [PATCH 4/4] Add a test for sqpoll sq_thread_idle_us mode Reviewed-by: Xiaoguang Wang Signed-off-by: Hao Xu --- - test/Makefile | 4 +- + test/Makefile | 1 + test/sqpoll-idle-us.c | 98 +++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 100 insertions(+), 2 deletions(-) + 2 files changed, 99 insertions(+) create mode 100644 test/sqpoll-idle-us.c diff --git a/test/Makefile b/test/Makefile -index 0720dcd..b58858b 100644 +index e14eb51..6efac71 100644 --- a/test/Makefile +++ b/test/Makefile -@@ -26,7 +26,7 @@ all_targets += poll poll-cancel ring-leak fsync io_uring_setup io_uring_register - send_recv eventfd-ring across-fork sq-poll-kthread splice \ - lfs-openat lfs-openat-write iopoll d4ae271dfaae-test \ - eventfd-disable close-opath ce593a6c480a-test cq-overflow-peek \ -- timeout-new -+ timeout-new sqpoll-idle-us - - include ../Makefile.quiet - -@@ -67,7 +67,7 @@ test_srcs := poll.c poll-cancel.c ring-leak.c fsync.c io_uring_setup.c \ - personality.c eventfd.c eventfd-ring.c across-fork.c sq-poll-kthread.c \ - splice.c lfs-openat.c lfs-openat-write.c iopoll.c d4ae271dfaae-test.c \ - eventfd-disable.c close-opath.c ce593a6c480a-test.c cq-overflow-peek.c \ -- timeout-new.c -+ timeout-new.c sqpoll-idle-us.c - - ifdef CONFIG_HAVE_STATX - test_srcs += statx.c +@@ -158,6 +158,7 @@ test_srcs := \ + sqpoll-disable-exit.c \ + sq-poll-dup.c \ + sqpoll-exit-hang.c \ ++ sqpoll-idle-us.c \ + sq-poll-kthread.c \ + sq-poll-share.c \ + sqpoll-sleep.c \ diff --git a/test/sqpoll-idle-us.c b/test/sqpoll-idle-us.c new file mode 100644 index 0000000..957ea7c diff --git a/1004-liburing-anolis-Revert-src-include-liburing-barrier.h-Use-C11-atomic.patch b/1004-liburing-anolis-Revert-src-include-liburing-barrier.h-Use-C11-atomic.patch deleted file mode 100644 index cb41bed2c5a50fb8b3e5707967f933c562383560..0000000000000000000000000000000000000000 --- a/1004-liburing-anolis-Revert-src-include-liburing-barrier.h-Use-C11-atomic.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 1fc7bb3aecf344847d13d0c3c25e1b98d1687219 Mon Sep 17 00:00:00 2001 -From: Hao Xu -Date: Thu, 12 Nov 2020 19:26:04 +0800 -Subject: [PATCH 3/3] Revert "src/include/liburing/barrier.h: Use C11 atomics" - -This reverts commit b9c0bf79aa879727f55f4fe7333dd41bebd0acd4. ---- - src/include/liburing/barrier.h | 44 ++++++++++++++++++++++++++++++++---------- - 1 file changed, 34 insertions(+), 10 deletions(-) - -diff --git a/src/include/liburing/barrier.h b/src/include/liburing/barrier.h -index c8aa4210371c..ad69506bb248 100644 ---- a/src/include/liburing/barrier.h -+++ b/src/include/liburing/barrier.h -@@ -2,8 +2,6 @@ - #ifndef LIBURING_BARRIER_H - #define LIBURING_BARRIER_H - --#include -- - /* - From the kernel documentation file refcount-vs-atomic.rst: - -@@ -23,14 +21,40 @@ after the acquire operation executes. This is implemented using - :c:func:`smp_acquire__after_ctrl_dep`. - */ - --#define IO_URING_WRITE_ONCE(var, val) \ -- atomic_store_explicit(&(var), (val), memory_order_relaxed) --#define IO_URING_READ_ONCE(var) \ -- atomic_load_explicit(&(var), memory_order_relaxed) -+/* From tools/include/linux/compiler.h */ -+/* Optimization barrier */ -+/* The "volatile" is due to gcc bugs */ -+#define io_uring_barrier() __asm__ __volatile__("": : :"memory") -+ -+/* From tools/virtio/linux/compiler.h */ -+#define IO_URING_WRITE_ONCE(var, val) \ -+ (*((volatile __typeof(val) *)(&(var))) = (val)) -+#define IO_URING_READ_ONCE(var) (*((volatile __typeof(var) *)(&(var)))) -+ - --#define io_uring_smp_store_release(p, v) \ -- atomic_store_explicit((p), (v), memory_order_release) --#define io_uring_smp_load_acquire(p) \ -- atomic_load_explicit((p), memory_order_acquire) -+#if defined(__x86_64__) || defined(__i386__) -+/* Adapted from arch/x86/include/asm/barrier.h */ -+#define io_uring_smp_store_release(p, v) \ -+do { \ -+ io_uring_barrier(); \ -+ IO_URING_WRITE_ONCE(*(p), (v)); \ -+} while (0) -+ -+#define io_uring_smp_load_acquire(p) \ -+({ \ -+ __typeof(*p) ___p1 = IO_URING_READ_ONCE(*(p)); \ -+ io_uring_barrier(); \ -+ ___p1; \ -+}) -+ -+#else /* defined(__x86_64__) || defined(__i386__) */ -+/* -+ * Add arch appropriate definitions. Use built-in atomic operations for -+ * archs we don't have support for. -+ */ -+#define io_uring_smp_store_release(p, v) \ -+ __atomic_store_n(p, v, __ATOMIC_RELEASE) -+#define io_uring_smp_load_acquire(p) __atomic_load_n(p, __ATOMIC_ACQUIRE) -+#endif /* defined(__x86_64__) || defined(__i386__) */ - - #endif /* defined(LIBURING_BARRIER_H) */ --- -1.8.3.1 - diff --git a/1005-liburing-anolis-sq_ring_needs_enter-revert-change-to-only-enter-if-s.patch b/1005-liburing-anolis-sq_ring_needs_enter-revert-change-to-only-enter-if-s.patch deleted file mode 100644 index e0d64f34fd1ae2c7f6dade75b46c52912cf1deb9..0000000000000000000000000000000000000000 --- a/1005-liburing-anolis-sq_ring_needs_enter-revert-change-to-only-enter-if-s.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 07b476fc25e29dda33b83e540d054bd95b82bb1e Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Thu, 20 Aug 2020 21:40:16 -0600 -Subject: [PATCH 1/8] sq_ring_needs_enter: revert change to only enter if - submit != 0 - -This reverts commit f0c5c54945ae92a00cdbb43bdf3abaeab6bd3a23. - -Glauber reports a regressions for his polled setup with this change. -As it's purely speculative, just revert it. - -Reported-by: Glauber Costa -Signed-off-by: Jens Axboe ---- - src/queue.c | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/src/queue.c b/src/queue.c -index be80d7a2c760..bdb473c1ba19 100644 ---- a/src/queue.c -+++ b/src/queue.c -@@ -19,10 +19,9 @@ - * or if IORING_SQ_NEED_WAKEUP is set, so submit thread must be explicitly - * awakened. For the latter case, we set the thread wakeup flag. - */ --static inline bool sq_ring_needs_enter(struct io_uring *ring, -- unsigned submitted, unsigned *flags) -+static inline bool sq_ring_needs_enter(struct io_uring *ring, unsigned *flags) - { -- if (!(ring->flags & IORING_SETUP_SQPOLL) && submitted) -+ if (!(ring->flags & IORING_SETUP_SQPOLL)) - return true; - if (IO_URING_READ_ONCE(*ring->sq.kflags) & IORING_SQ_NEED_WAKEUP) { - *flags |= IORING_ENTER_SQ_WAKEUP; -@@ -90,7 +89,7 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, - if (wait_nr || cq_overflow_flush) - flags = IORING_ENTER_GETEVENTS; - if (submit) -- sq_ring_needs_enter(ring, submit, &flags); -+ sq_ring_needs_enter(ring, &flags); - if (wait_nr || submit || cq_overflow_flush) - ret = __sys_io_uring_enter(ring->ring_fd, submit, - wait_nr, flags, sigmask); -@@ -256,7 +255,7 @@ static int __io_uring_submit(struct io_uring *ring, unsigned submitted, - int ret; - - flags = 0; -- if (sq_ring_needs_enter(ring, submitted, &flags) || wait_nr) { -+ if (sq_ring_needs_enter(ring, &flags) || wait_nr) { - if (wait_nr || (ring->flags & IORING_SETUP_IOPOLL)) - flags |= IORING_ENTER_GETEVENTS; - --- -1.8.3.1 - diff --git a/1005-test-io_uring_passthrough-skip-if-kernel-doesn-t-sup.patch b/1005-test-io_uring_passthrough-skip-if-kernel-doesn-t-sup.patch new file mode 100644 index 0000000000000000000000000000000000000000..f77be96269a83255ebec24acefba35e916d4b72d --- /dev/null +++ b/1005-test-io_uring_passthrough-skip-if-kernel-doesn-t-sup.patch @@ -0,0 +1,57 @@ +From 626d52adaffc193597ff0294be50611540a6233c Mon Sep 17 00:00:00 2001 +From: Jens Axboe +Date: Wed, 30 Nov 2022 20:37:12 -0700 +Subject: [PATCH 1/4] test/io_uring_passthrough: skip if kernel doesn't support + passthrough + +If we get -EOPNOTSUPP, just skip the test at our earliest convenience. + +Signed-off-by: Jens Axboe +Signed-off-by: Joseph Qi +--- + test/io_uring_passthrough.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c +index ee9ab87..2f24364 100644 +--- a/test/io_uring_passthrough.c ++++ b/test/io_uring_passthrough.c +@@ -18,6 +18,7 @@ + #define BUFFERS (FILE_SIZE / BS) + + static struct iovec *vecs; ++static int no_pt; + + /* + * Each offset in the file has the ((test_case / 2) * FILE_SIZE) +@@ -205,6 +206,10 @@ static int __test_io(const char *file, struct io_uring *ring, int tc, int read, + goto err; + } + if (cqe->res != 0) { ++ if (!no_pt) { ++ no_pt = 1; ++ goto skip; ++ } + fprintf(stderr, "cqe res %d, wanted 0\n", cqe->res); + goto err; + } +@@ -234,6 +239,7 @@ static int __test_io(const char *file, struct io_uring *ring, int tc, int read, + } + } + ++skip: + close(fd); + return 0; + err: +@@ -431,6 +437,8 @@ int main(int argc, char *argv[]) + read, sqthread, fixed, nonvec); + goto err; + } ++ if (no_pt) ++ return T_EXIT_SKIP; + } + + ret = test_io_uring_submit_enters(fname); +-- +2.24.4 + diff --git a/1006-liburing-anolis-io_uring.h-update-with-5.11-pending-copy.patch b/1006-liburing-anolis-io_uring.h-update-with-5.11-pending-copy.patch deleted file mode 100644 index 418f34266901346d1ba398dae68b50f96b781fb7..0000000000000000000000000000000000000000 --- a/1006-liburing-anolis-io_uring.h-update-with-5.11-pending-copy.patch +++ /dev/null @@ -1,51 +0,0 @@ -From a3680c5479fb84ebc224f4626c361ec1293c1f31 Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Wed, 4 Nov 2020 11:25:55 -0700 -Subject: [PATCH 2/8] io_uring.h: update with 5.11-pending copy - -Backport Notes - -manully backport struct io_uring_getevents_arg since the patch -0002-Revert-Make-the-liburing-header-files-again-compatib.patch -stoped the auto backporting - -Signed-off-by: Jens Axboe ---- - src/include/liburing/io_uring.h | 9 +++++++++ - 1 file changed, 9 insertions(+) - -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index c55878e0a200..7f7701c86eb4 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -226,6 +226,7 @@ struct io_cqring_offsets { - */ - #define IORING_ENTER_GETEVENTS (1U << 0) - #define IORING_ENTER_SQ_WAKEUP (1U << 1) -+#define IORING_ENTER_GETEVENTS_TIMEOUT (1U << 3) - - /* - * Passed in for io_uring_setup(2). Copied back with updated info on success -@@ -253,6 +254,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 << 8) - - /* - * io_uring_register(2) opcodes and arguments -@@ -292,4 +294,11 @@ struct io_uring_probe { - struct io_uring_probe_op ops[0]; - }; - -+struct io_uring_getevents_arg { -+ __u64 sigmask; -+ __u32 sigmask_sz; -+ __u32 pad; -+ __u64 ts; -+}; -+ - #endif --- -1.8.3.1 - diff --git a/1006-test-io_uring_passthrough-fix-iopoll-test.patch b/1006-test-io_uring_passthrough-fix-iopoll-test.patch new file mode 100644 index 0000000000000000000000000000000000000000..18944ced67b437f1ebbbaad062f21da5b53b7825 --- /dev/null +++ b/1006-test-io_uring_passthrough-fix-iopoll-test.patch @@ -0,0 +1,65 @@ +From 49425e0b44cf7b46f022ddabee73a0630cb1f9bc Mon Sep 17 00:00:00 2001 +From: Kanchan Joshi +Date: Tue, 6 Dec 2022 17:48:30 +0530 +Subject: [PATCH 2/4] test/io_uring_passthrough: fix iopoll test + +iopoll test is broken as it does not initialize the command/sqe properly +before submission. +Add the necessary initialization to set this right. + +Signed-off-by: Kanchan Joshi +Link: https://lore.kernel.org/r/20221206121831.5528-2-joshi.k@samsung.com +Signed-off-by: Jens Axboe +Signed-off-by: Joseph Qi +--- + test/io_uring_passthrough.c | 24 +++++++++++++++++++++--- + 1 file changed, 21 insertions(+), 3 deletions(-) + +diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c +index 2f24364..933c137 100644 +--- a/test/io_uring_passthrough.c ++++ b/test/io_uring_passthrough.c +@@ -352,6 +352,8 @@ static int test_io_uring_submit_enters(const char *file) + int fd, i, ret, ring_flags, open_flags; + unsigned head; + struct io_uring_cqe *cqe; ++ struct nvme_uring_cmd *cmd; ++ struct io_uring_sqe *sqe; + + ring_flags = IORING_SETUP_IOPOLL; + ring_flags |= IORING_SETUP_SQE128; +@@ -371,12 +373,28 @@ static int test_io_uring_submit_enters(const char *file) + } + + for (i = 0; i < BUFFERS; i++) { +- struct io_uring_sqe *sqe; + off_t offset = BS * (rand() % BUFFERS); ++ __u64 slba; ++ __u32 nlb; + + sqe = io_uring_get_sqe(&ring); +- io_uring_prep_writev(sqe, fd, &vecs[i], 1, offset); +- sqe->user_data = 1; ++ io_uring_prep_readv(sqe, fd, &vecs[i], 1, offset); ++ sqe->user_data = i; ++ sqe->opcode = IORING_OP_URING_CMD; ++ sqe->cmd_op = NVME_URING_CMD_IO; ++ cmd = (struct nvme_uring_cmd *)sqe->cmd; ++ memset(cmd, 0, sizeof(struct nvme_uring_cmd)); ++ ++ slba = offset >> lba_shift; ++ nlb = (BS >> lba_shift) - 1; ++ ++ cmd->opcode = nvme_cmd_read; ++ cmd->cdw10 = slba & 0xffffffff; ++ cmd->cdw11 = slba >> 32; ++ cmd->cdw12 = nlb; ++ cmd->addr = (__u64)(uintptr_t)&vecs[i]; ++ cmd->data_len = 1; ++ cmd->nsid = nsid; + } + + /* submit manually to avoid adding IORING_ENTER_GETEVENTS */ +-- +2.24.4 + diff --git a/1007-liburing-anolis-Include-features-in-struct-io_uring.patch b/1007-liburing-anolis-Include-features-in-struct-io_uring.patch deleted file mode 100644 index b59f078ce2a4e17c6d135d4ae27374a5e015f8cf..0000000000000000000000000000000000000000 --- a/1007-liburing-anolis-Include-features-in-struct-io_uring.patch +++ /dev/null @@ -1,58 +0,0 @@ -From fc063be2896b15e8083d25f932758c34ef7b9540 Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Wed, 4 Nov 2020 11:35:41 -0700 -Subject: [PATCH 3/8] Include 'features' in struct io_uring - -Then we'll have it for later, should we need to know what features the -ring has. This grabs one of the reserved unsigneds from the struct. - -Backport Notes - -pad[4] in struct io_uring {} is introduced in -25bbcbef3e0a ("Bump major version to 2"), backporting it causes a chain -reaction of backporting __io_uring_sqring_wait(). So here we manully -add pad[3] - -Signed-off-by: Jens Axboe ---- - src/include/liburing.h | 3 +++ - src/setup.c | 7 +++++-- - 2 files changed, 8 insertions(+), 2 deletions(-) - -diff --git a/src/include/liburing.h b/src/include/liburing.h -index 92e5018951d4..ac2d4a1cbeba 100644 ---- a/src/include/liburing.h -+++ b/src/include/liburing.h -@@ -57,6 +57,9 @@ struct io_uring { - struct io_uring_cq cq; - unsigned flags; - int ring_fd; -+ -+ unsigned features; -+ unsigned pad[3]; - }; - - /* -diff --git a/src/setup.c b/src/setup.c -index 2b17b949cda6..260dd2be8e85 100644 ---- a/src/setup.c -+++ b/src/setup.c -@@ -142,10 +142,13 @@ int io_uring_queue_init_params(unsigned entries, struct io_uring *ring, - return -errno; - - ret = io_uring_queue_mmap(fd, p, ring); -- if (ret) -+ if (ret) { - close(fd); -+ return ret; -+ } - -- return ret; -+ ring->features = p->features; -+ return 0; - } - - /* --- -1.8.3.1 - diff --git a/1007-test-io_uring_passthrough-cleanup-invalid-submission.patch b/1007-test-io_uring_passthrough-cleanup-invalid-submission.patch new file mode 100644 index 0000000000000000000000000000000000000000..676472b90868e34c8f6f4d00fa04d27c9e0dd73e --- /dev/null +++ b/1007-test-io_uring_passthrough-cleanup-invalid-submission.patch @@ -0,0 +1,33 @@ +From 1985fba0acdac7addc3d8abb5db350a2a7648f16 Mon Sep 17 00:00:00 2001 +From: Kanchan Joshi +Date: Tue, 6 Dec 2022 17:48:31 +0530 +Subject: [PATCH 3/4] test/io_uring_passthrough: cleanup invalid submission + test + +Just do away with setting IOPOLL as this is not necessary for the test. + +Signed-off-by: Kanchan Joshi +Link: https://lore.kernel.org/r/20221206121831.5528-3-joshi.k@samsung.com +Signed-off-by: Jens Axboe +Signed-off-by: Joseph Qi +--- + test/io_uring_passthrough.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c +index 933c137..292e98d 100644 +--- a/test/io_uring_passthrough.c ++++ b/test/io_uring_passthrough.c +@@ -288,8 +288,7 @@ static int test_invalid_passthru_submit(const char *file) + struct io_uring_sqe *sqe; + struct nvme_uring_cmd *cmd; + +- ring_flags = IORING_SETUP_IOPOLL | IORING_SETUP_SQE128; +- ring_flags |= IORING_SETUP_CQE32; ++ ring_flags = IORING_SETUP_CQE32 | IORING_SETUP_SQE128; + + ret = t_create_ring(1, &ring, ring_flags); + if (ret != T_SETUP_OK) { +-- +2.24.4 + diff --git a/1008-liburing-anolis-Add-__sys_io_uring_enter2.patch b/1008-liburing-anolis-Add-__sys_io_uring_enter2.patch deleted file mode 100644 index 15bfae26895c5f75aeca891d999e8bd0fd0b2fa8..0000000000000000000000000000000000000000 --- a/1008-liburing-anolis-Add-__sys_io_uring_enter2.patch +++ /dev/null @@ -1,53 +0,0 @@ -From b1e4e2dfaa657de06a401d418e370b2b42e6ba3f Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Wed, 4 Nov 2020 11:55:25 -0700 -Subject: [PATCH 4/8] Add __sys_io_uring_enter2() - -Just like __sys_io_uring_enter(), except it allows passing in the size -of the last argument. - -Signed-off-by: Jens Axboe ---- - src/syscall.c | 11 +++++++++-- - src/syscall.h | 2 ++ - 2 files changed, 11 insertions(+), 2 deletions(-) - -diff --git a/src/syscall.c b/src/syscall.c -index c41e0998d0dd..9b455a911df8 100644 ---- a/src/syscall.c -+++ b/src/syscall.c -@@ -47,9 +47,16 @@ int __sys_io_uring_setup(unsigned entries, struct io_uring_params *p) - return syscall(__NR_io_uring_setup, entries, p); - } - -+int __sys_io_uring_enter2(int fd, unsigned to_submit, unsigned min_complete, -+ unsigned flags, sigset_t *sig, int sz) -+{ -+ return syscall(__NR_io_uring_enter, fd, to_submit, min_complete, -+ flags, sig, sz); -+} -+ - int __sys_io_uring_enter(int fd, unsigned to_submit, unsigned min_complete, - unsigned flags, sigset_t *sig) - { -- return syscall(__NR_io_uring_enter, fd, to_submit, min_complete, -- flags, sig, _NSIG / 8); -+ return __sys_io_uring_enter2(fd, to_submit, min_complete, flags, sig, -+ _NSIG / 8); - } -diff --git a/src/syscall.h b/src/syscall.h -index 7e299d419e3e..a4c8e9bbb3f7 100644 ---- a/src/syscall.h -+++ b/src/syscall.h -@@ -8,6 +8,8 @@ - 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); -+extern int __sys_io_uring_enter2(int fd, unsigned to_submit, -+ unsigned min_complete, unsigned flags, sigset_t *sig, int sz); - extern int __sys_io_uring_register(int fd, unsigned int opcode, const void *arg, - unsigned int nr_args); - --- -1.8.3.1 - diff --git a/1008-test-io_uring_passthrough-skip-test-if-bit-sqe-cqe-s.patch b/1008-test-io_uring_passthrough-skip-test-if-bit-sqe-cqe-s.patch new file mode 100644 index 0000000000000000000000000000000000000000..0a9f5cc3038edb22cf4c483a27e8d4568d659c9b --- /dev/null +++ b/1008-test-io_uring_passthrough-skip-test-if-bit-sqe-cqe-s.patch @@ -0,0 +1,51 @@ +From a0226c19959dda7e1008d0ff77f57264d7f7fdef Mon Sep 17 00:00:00 2001 +From: Jens Axboe +Date: Fri, 23 Dec 2022 08:55:41 -0700 +Subject: [PATCH 4/4] test/io_uring_passthrough: skip test if bit sqe/cqe + support not there + +Signed-off-by: Jens Axboe +Signed-off-by: Joseph Qi +--- + test/io_uring_passthrough.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/test/io_uring_passthrough.c b/test/io_uring_passthrough.c +index 292e98d..8fbafdb 100644 +--- a/test/io_uring_passthrough.c ++++ b/test/io_uring_passthrough.c +@@ -264,6 +264,10 @@ static int test_io(const char *file, int tc, int read, int sqthread, + if (ret == T_SETUP_SKIP) + return 0; + if (ret != T_SETUP_OK) { ++ if (ret == -EINVAL) { ++ no_pt = 1; ++ return T_SETUP_SKIP; ++ } + fprintf(stderr, "ring create failed: %d\n", ret); + return 1; + } +@@ -449,15 +453,18 @@ int main(int argc, char *argv[]) + int nonvec = (i & 8) != 0; + + ret = test_io(fname, i, read, sqthread, fixed, nonvec); ++ if (no_pt) ++ break; + if (ret) { + fprintf(stderr, "test_io failed %d/%d/%d/%d\n", + read, sqthread, fixed, nonvec); + goto err; + } +- if (no_pt) +- return T_EXIT_SKIP; + } + ++ if (no_pt) ++ return T_EXIT_SKIP; ++ + ret = test_io_uring_submit_enters(fname); + if (ret) { + fprintf(stderr, "test_io_uring_submit_enters failed\n"); +-- +2.24.4 + diff --git a/1009-liburing-anolis-Add-wrapper-for-__io_uring_get_cqe.patch b/1009-liburing-anolis-Add-wrapper-for-__io_uring_get_cqe.patch deleted file mode 100644 index a0b6ab4950e99922399d91614c0320cffdd24715..0000000000000000000000000000000000000000 --- a/1009-liburing-anolis-Add-wrapper-for-__io_uring_get_cqe.patch +++ /dev/null @@ -1,117 +0,0 @@ -From 12d141534e1747525656087b357440cc68a43fda Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Wed, 4 Nov 2020 11:44:48 -0700 -Subject: [PATCH 5/8] Add wrapper for __io_uring_get_cqe() - -In preparation for allowing passing in a timeout. - -Signed-off-by: Jens Axboe ---- - src/queue.c | 58 ++++++++++++++++++++++++++++++++++++++++++---------------- - 1 file changed, 42 insertions(+), 16 deletions(-) - -diff --git a/src/queue.c b/src/queue.c -index bdb473c1ba19..3f3099be8a6d 100644 ---- a/src/queue.c -+++ b/src/queue.c -@@ -63,11 +63,19 @@ static int __io_uring_peek_cqe(struct io_uring *ring, - return err; - } - --int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, -- unsigned submit, unsigned wait_nr, sigset_t *sigmask) -+struct get_data { -+ unsigned submit; -+ unsigned wait_nr; -+ unsigned get_flags; -+ int sz; -+ void *arg; -+}; -+ -+static int _io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, -+ struct get_data *data) - { - struct io_uring_cqe *cqe = NULL; -- const int to_wait = wait_nr; -+ const int to_wait = data->wait_nr; - int ret = 0, err; - - do { -@@ -77,26 +85,30 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, - err = __io_uring_peek_cqe(ring, &cqe); - if (err) - break; -- if (!cqe && !to_wait && !submit) { -+ -+ if (!cqe && !to_wait && !data->submit) { - if (!cq_ring_needs_flush(ring)) { - err = -EAGAIN; - break; - } - cq_overflow_flush = true; - } -- if (wait_nr && cqe) -- wait_nr--; -- if (wait_nr || cq_overflow_flush) -- flags = IORING_ENTER_GETEVENTS; -- if (submit) -+ -+ if (data->wait_nr && cqe) -+ data->wait_nr--; -+ if (data->wait_nr || cq_overflow_flush) -+ flags = IORING_ENTER_GETEVENTS | data->get_flags; -+ if (data->submit) - sq_ring_needs_enter(ring, &flags); -- if (wait_nr || submit || cq_overflow_flush) -- ret = __sys_io_uring_enter(ring->ring_fd, submit, -- wait_nr, flags, sigmask); -+ if (data->wait_nr || data->submit || cq_overflow_flush) -+ ret = __sys_io_uring_enter2(ring->ring_fd, data->submit, -+ data->wait_nr, flags, data->arg, -+ data->sz); -+ - if (ret < 0) { - err = -errno; -- } else if (ret == (int)submit) { -- submit = 0; -+ } else if (ret == (int)data->submit) { -+ data->submit = 0; - /* - * When SETUP_IOPOLL is set, __sys_io_uring enter() - * must be called to reap new completions but the call -@@ -104,9 +116,9 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, - * so preserve wait_nr. - */ - if (!(ring->flags & IORING_SETUP_IOPOLL)) -- wait_nr = 0; -+ data->wait_nr = 0; - } else { -- submit -= ret; -+ data->submit -= ret; - } - if (cqe) - break; -@@ -116,6 +128,20 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, - return err; - } - -+int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, -+ unsigned submit, unsigned wait_nr, sigset_t *sigmask) -+{ -+ struct get_data data = { -+ .submit = submit, -+ .wait_nr = wait_nr, -+ .extra_flags = 0, -+ .sz = _NSIG / 8, -+ .arg = sigmask, -+ }; -+ -+ return _io_uring_get_cqe(ring, cqe_ptr, &data); -+} -+ - /* - * Fill in an array of IO completions up to count, if any are available. - * Returns the amount of IO completions filled. --- -1.8.3.1 - diff --git a/1010-liburing-anolis-Use-IORING_ENTER_GETEVENTS_TIMEOUT-if-available.patch b/1010-liburing-anolis-Use-IORING_ENTER_GETEVENTS_TIMEOUT-if-available.patch deleted file mode 100644 index c650c9b0e0df88dfd80ac533c83aabfdd94af628..0000000000000000000000000000000000000000 --- a/1010-liburing-anolis-Use-IORING_ENTER_GETEVENTS_TIMEOUT-if-available.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 91a6a81fc75c8f02b8c5b6b2b069dd3d1e96f6b9 Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Wed, 4 Nov 2020 12:02:28 -0700 -Subject: [PATCH 6/8] Use IORING_ENTER_GETEVENTS_TIMEOUT if available - -If the kernel has flagged support for IORING_FEAT_GETEVENTS_TIMEOUT, -then we can pass in a timespec instead of queueing an internal timeout -request. That's more efficient (and trivial), so use it if it's -available. - -Signed-off-by: Jens Axboe ---- - src/queue.c | 28 ++++++++++++++++++++++++++++ - 1 file changed, 28 insertions(+) - -diff --git a/src/queue.c b/src/queue.c -index 3f3099be8a6d..cd800fc5b6e8 100644 ---- a/src/queue.c -+++ b/src/queue.c -@@ -218,6 +218,31 @@ out: - } - - /* -+ * If we have kernel suppor for IORING_ENTER_GETEVENTS_TIMEOUT, then we can -+ * use that more efficiently than queueing an internal timeout command. -+ */ -+static int io_uring_wait_cqes_new(struct io_uring *ring, -+ struct io_uring_cqe **cqe_ptr, -+ unsigned wait_nr, struct __kernel_timespec *ts, -+ sigset_t *sigmask) -+{ -+ struct io_uring_getevents_arg arg = { -+ .sigmask = (unsigned long) sigmask, -+ .sigmask_sz = _NSIG / 8, -+ .ts = (unsigned long) ts -+ }; -+ struct get_data data = { -+ .submit = __io_uring_flush_sq(ring), -+ .wait_nr = wait_nr, -+ .extra_flags = ts ? IORING_ENTER_GETEVENTS_TIMEOUT : 0, -+ .sz = sizeof(arg), -+ .arg = &arg -+ }; -+ -+ return _io_uring_get_cqe(ring, cqe_ptr, &data); -+} -+ -+/* - * Like io_uring_wait_cqe(), except it accepts a timeout value as well. Note - * that an sqe is used internally to handle the timeout. Applications using - * this function must never set sqe->user_data to LIBURING_UDATA_TIMEOUT! -@@ -234,6 +259,9 @@ int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, - { - unsigned to_submit = 0; - -+ if (ring->features & IORING_FEAT_GETEVENTS_TIMEOUT) -+ return io_uring_wait_cqes_new(ring, cqe_ptr, wait_nr, ts, sigmask); -+ - if (ts) { - struct io_uring_sqe *sqe; - int ret; --- -1.8.3.1 - diff --git a/1011-liburing-anolis-Update-SIG_IS_DATA-to-modified-kernel-API.patch b/1011-liburing-anolis-Update-SIG_IS_DATA-to-modified-kernel-API.patch deleted file mode 100644 index 67ecab48e8ede0cf7b1f348b705fc4ef90d38bd9..0000000000000000000000000000000000000000 --- a/1011-liburing-anolis-Update-SIG_IS_DATA-to-modified-kernel-API.patch +++ /dev/null @@ -1,78 +0,0 @@ -From dd75ea9d5ef1eceba7b1e49b437a08c8a2753364 Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Wed, 4 Nov 2020 13:57:17 -0700 -Subject: [PATCH 7/8] Update SIG_IS_DATA to modified kernel API - -Still ironing out the kinks... - -Signed-off-by: Jens Axboe ---- - src/include/liburing/io_uring.h | 4 ++-- - src/queue.c | 8 ++++---- - 2 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index 7f7701c86eb4..b892dbe77d86 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -226,7 +226,7 @@ struct io_cqring_offsets { - */ - #define IORING_ENTER_GETEVENTS (1U << 0) - #define IORING_ENTER_SQ_WAKEUP (1U << 1) --#define IORING_ENTER_GETEVENTS_TIMEOUT (1U << 3) -+#define IORING_ENTER_SIG_IS_DATA (1U << 3) - - /* - * Passed in for io_uring_setup(2). Copied back with updated info on success -@@ -254,7 +254,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 << 8) -+#define IORING_FEAT_SIG_IS_DATA (1U << 8) - - /* - * io_uring_register(2) opcodes and arguments -diff --git a/src/queue.c b/src/queue.c -index cd800fc5b6e8..6df391c33c6f 100644 ---- a/src/queue.c -+++ b/src/queue.c -@@ -134,7 +134,7 @@ int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, - struct get_data data = { - .submit = submit, - .wait_nr = wait_nr, -- .extra_flags = 0, -+ .get_flags = 0, - .sz = _NSIG / 8, - .arg = sigmask, - }; -@@ -218,7 +218,7 @@ out: - } - - /* -- * If we have kernel suppor for IORING_ENTER_GETEVENTS_TIMEOUT, then we can -+ * If we have kernel support for IORING_ENTERSIG_IS_DATA, then we can - * use that more efficiently than queueing an internal timeout command. - */ - static int io_uring_wait_cqes_new(struct io_uring *ring, -@@ -234,7 +234,7 @@ static int io_uring_wait_cqes_new(struct io_uring *ring, - struct get_data data = { - .submit = __io_uring_flush_sq(ring), - .wait_nr = wait_nr, -- .extra_flags = ts ? IORING_ENTER_GETEVENTS_TIMEOUT : 0, -+ .get_flags = ts ? IORING_ENTER_SIG_IS_DATA : 0, - .sz = sizeof(arg), - .arg = &arg - }; -@@ -259,7 +259,7 @@ int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, - { - unsigned to_submit = 0; - -- if (ring->features & IORING_FEAT_GETEVENTS_TIMEOUT) -+ if (ring->features & IORING_FEAT_SIG_IS_DATA) - return io_uring_wait_cqes_new(ring, cqe_ptr, wait_nr, ts, sigmask); - - if (ts) { --- -1.8.3.1 - diff --git a/1012-liburing-anolis-Rename-SIG_IS_DATA-EXT_ARG.patch b/1012-liburing-anolis-Rename-SIG_IS_DATA-EXT_ARG.patch deleted file mode 100644 index 8f39924fc913a75cd31fcb507e6a1c74aef1f011..0000000000000000000000000000000000000000 --- a/1012-liburing-anolis-Rename-SIG_IS_DATA-EXT_ARG.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 8424cff4705e62784b8042d71e12e22554a038ac Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Wed, 4 Nov 2020 14:34:03 -0700 -Subject: [PATCH 8/8] Rename SIG_IS_DATA -> EXT_ARG - -This is the final name. While doing this change, also change it so that -we only call the new variant if 'ts' is indeed set. - -Signed-off-by: Jens Axboe ---- - src/include/liburing/io_uring.h | 4 ++-- - src/queue.c | 13 +++++++------ - 2 files changed, 9 insertions(+), 8 deletions(-) - -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index b892dbe77d86..e8393b87e7bd 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -226,7 +226,7 @@ struct io_cqring_offsets { - */ - #define IORING_ENTER_GETEVENTS (1U << 0) - #define IORING_ENTER_SQ_WAKEUP (1U << 1) --#define IORING_ENTER_SIG_IS_DATA (1U << 3) -+#define IORING_ENTER_EXT_ARG (1U << 3) - - /* - * Passed in for io_uring_setup(2). Copied back with updated info on success -@@ -254,7 +254,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_SIG_IS_DATA (1U << 8) -+#define IORING_FEAT_EXT_ARG (1U << 8) - - /* - * io_uring_register(2) opcodes and arguments -diff --git a/src/queue.c b/src/queue.c -index 6df391c33c6f..2662e671fb34 100644 ---- a/src/queue.c -+++ b/src/queue.c -@@ -218,8 +218,8 @@ out: - } - - /* -- * If we have kernel support for IORING_ENTERSIG_IS_DATA, then we can -- * use that more efficiently than queueing an internal timeout command. -+ * If we have kernel support for IORING_ENTER_EXT_ARG, then we can use that -+ * more efficiently than queueing an internal timeout command. - */ - static int io_uring_wait_cqes_new(struct io_uring *ring, - struct io_uring_cqe **cqe_ptr, -@@ -234,7 +234,7 @@ static int io_uring_wait_cqes_new(struct io_uring *ring, - struct get_data data = { - .submit = __io_uring_flush_sq(ring), - .wait_nr = wait_nr, -- .get_flags = ts ? IORING_ENTER_SIG_IS_DATA : 0, -+ .get_flags = IORING_ENTER_EXT_ARG, - .sz = sizeof(arg), - .arg = &arg - }; -@@ -259,13 +259,14 @@ int io_uring_wait_cqes(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, - { - unsigned to_submit = 0; - -- if (ring->features & IORING_FEAT_SIG_IS_DATA) -- return io_uring_wait_cqes_new(ring, cqe_ptr, wait_nr, ts, sigmask); -- - if (ts) { - struct io_uring_sqe *sqe; - int ret; - -+ if (ring->features & IORING_FEAT_EXT_ARG) -+ return io_uring_wait_cqes_new(ring, cqe_ptr, wait_nr, -+ ts, sigmask); -+ - /* - * If the SQ ring is full, we may need to submit IO first - */ --- -1.8.3.1 - diff --git a/1013-liburing-anolis-test-timeout-new-test-for-timeout-feature.patch b/1013-liburing-anolis-test-timeout-new-test-for-timeout-feature.patch deleted file mode 100644 index 0037a516fa326211bf58b5490e40cc51e92c4885..0000000000000000000000000000000000000000 --- a/1013-liburing-anolis-test-timeout-new-test-for-timeout-feature.patch +++ /dev/null @@ -1,307 +0,0 @@ -From ce520b2655e8d14d3a94cc9f596f128eb4c36140 Mon Sep 17 00:00:00 2001 -From: Hao Xu -Date: Sat, 12 Dec 2020 12:49:39 +0800 -Subject: [PATCH] test/timeout-new: test for timeout feature - -Tests for the new timeout feature. It covers: - - wake up when timeout, sleeping time calculated as well - - wake up by a cqe before timeout - - the above two in sqpoll thread mode - - multi child-threads wake up by a cqe issuing in main thread before - timeout - -Signed-off-by: Hao Xu -Signed-off-by: Jens Axboe ---- - test/Makefile | 7 +- - test/timeout-new.c | 246 +++++++++++++++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 251 insertions(+), 2 deletions(-) - create mode 100644 test/timeout-new.c - -diff --git a/test/Makefile b/test/Makefile -index cbbd400391dd..0720dcd39950 100644 ---- a/test/Makefile -+++ b/test/Makefile -@@ -25,7 +25,8 @@ all_targets += poll poll-cancel ring-leak fsync io_uring_setup io_uring_register - short-read openat2 probe shared-wq personality eventfd \ - send_recv eventfd-ring across-fork sq-poll-kthread splice \ - lfs-openat lfs-openat-write iopoll d4ae271dfaae-test \ -- eventfd-disable close-opath ce593a6c480a-test cq-overflow-peek -+ eventfd-disable close-opath ce593a6c480a-test cq-overflow-peek \ -+ timeout-new - - include ../Makefile.quiet - -@@ -65,7 +66,8 @@ test_srcs := poll.c poll-cancel.c ring-leak.c fsync.c io_uring_setup.c \ - madvise.c short-read.c openat2.c probe.c shared-wq.c \ - personality.c eventfd.c eventfd-ring.c across-fork.c sq-poll-kthread.c \ - splice.c lfs-openat.c lfs-openat-write.c iopoll.c d4ae271dfaae-test.c \ -- eventfd-disable.c close-opath.c ce593a6c480a-test.c cq-overflow-peek.c -+ eventfd-disable.c close-opath.c ce593a6c480a-test.c cq-overflow-peek.c \ -+ timeout-new.c - - ifdef CONFIG_HAVE_STATX - test_srcs += statx.c -@@ -87,6 +89,7 @@ submit-reuse: XCFLAGS = -lpthread - poll-v-poll: XCFLAGS = -lpthread - across-fork: XCFLAGS = -lpthread - ce593a6c480a-test: XCFLAGS = -lpthread -+timeout-new: XCFLAGS = -lpthread - - install: $(all_targets) runtests.sh runtests-loop.sh - $(INSTALL) -D -d -m 755 $(datadir)/liburing-test/ -diff --git a/test/timeout-new.c b/test/timeout-new.c -new file mode 100644 -index 000000000000..45b9a149ae11 ---- /dev/null -+++ b/test/timeout-new.c -@@ -0,0 +1,246 @@ -+/* SPDX-License-Identifier: MIT */ -+/* -+ * Description: tests for getevents timeout -+ * -+ */ -+#include -+#include -+#include -+#include -+#include "liburing.h" -+ -+#define TIMEOUT_MSEC 200 -+#define TIMEOUT_SEC 10 -+ -+int thread_ret0, thread_ret1; -+int cnt = 0; -+pthread_mutex_t mutex; -+ -+static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec) -+{ -+ ts->tv_sec = msec / 1000; -+ ts->tv_nsec = (msec % 1000) * 1000000; -+} -+ -+static unsigned long long mtime_since(const struct timeval *s, -+ const struct timeval *e) -+{ -+ long long sec, usec; -+ -+ sec = e->tv_sec - s->tv_sec; -+ usec = (e->tv_usec - s->tv_usec); -+ if (sec > 0 && usec < 0) { -+ sec--; -+ usec += 1000000; -+ } -+ -+ sec *= 1000; -+ usec /= 1000; -+ return sec + usec; -+} -+ -+static unsigned long long mtime_since_now(struct timeval *tv) -+{ -+ struct timeval end; -+ -+ gettimeofday(&end, NULL); -+ return mtime_since(tv, &end); -+} -+ -+ -+static int test_return_before_timeout(struct io_uring *ring) -+{ -+ struct io_uring_cqe *cqe; -+ struct io_uring_sqe *sqe; -+ int ret; -+ struct __kernel_timespec ts; -+ -+ sqe = io_uring_get_sqe(ring); -+ if (!sqe) { -+ fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__); -+ return 1; -+ } -+ -+ io_uring_prep_nop(sqe); -+ -+ ret = io_uring_submit(ring); -+ if (ret <= 0) { -+ fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret); -+ return 1; -+ } -+ -+ msec_to_ts(&ts, TIMEOUT_MSEC); -+ ret = io_uring_wait_cqe_timeout(ring, &cqe, &ts); -+ if (ret < 0) { -+ fprintf(stderr, "%s: timeout error: %d\n", __FUNCTION__, ret); -+ return 1; -+ } -+ -+ io_uring_cqe_seen(ring, cqe); -+ return 0; -+} -+ -+static int test_return_after_timeout(struct io_uring *ring) -+{ -+ struct io_uring_cqe *cqe; -+ int ret; -+ struct __kernel_timespec ts; -+ struct timeval tv; -+ unsigned long long exp; -+ -+ msec_to_ts(&ts, TIMEOUT_MSEC); -+ gettimeofday(&tv, NULL); -+ ret = io_uring_wait_cqe_timeout(ring, &cqe, &ts); -+ exp = mtime_since_now(&tv); -+ if (ret != -ETIME) { -+ fprintf(stderr, "%s: timeout error: %d\n", __FUNCTION__, ret); -+ return 1; -+ } -+ -+ if (exp < TIMEOUT_MSEC / 2 || exp > (TIMEOUT_MSEC * 3) / 2) { -+ fprintf(stderr, "%s: Timeout seems wonky (got %llu)\n", __FUNCTION__, exp); -+ return 1; -+ } -+ -+ return 0; -+} -+ -+int __reap_thread_fn(void *data) { -+ struct io_uring *ring = (struct io_uring *)data; -+ struct io_uring_cqe *cqe; -+ struct __kernel_timespec ts; -+ -+ msec_to_ts(&ts, TIMEOUT_SEC); -+ pthread_mutex_lock(&mutex); -+ cnt++; -+ pthread_mutex_unlock(&mutex); -+ return io_uring_wait_cqe_timeout(ring, &cqe, &ts); -+} -+ -+void *reap_thread_fn0(void *data) { -+ thread_ret0 = __reap_thread_fn(data); -+ return NULL; -+} -+ -+void *reap_thread_fn1(void *data) { -+ thread_ret1 = __reap_thread_fn(data); -+ return NULL; -+} -+ -+/* -+ * This is to test issuing a sqe in main thread and reaping it in two child-thread -+ * at the same time. To see if timeout feature works or not. -+ */ -+int test_multi_threads_timeout() { -+ struct io_uring ring; -+ int ret; -+ bool both_wait = false; -+ pthread_t reap_thread0, reap_thread1; -+ struct io_uring_sqe *sqe; -+ -+ ret = io_uring_queue_init(8, &ring, 0); -+ if (ret) { -+ fprintf(stderr, "%s: ring setup failed: %d\n", __FUNCTION__, ret); -+ return 1; -+ } -+ -+ pthread_create(&reap_thread0, NULL, reap_thread_fn0, &ring); -+ pthread_create(&reap_thread1, NULL, reap_thread_fn1, &ring); -+ -+ /* -+ * make two threads both enter io_uring_wait_cqe_timeout() before issuing the sqe -+ * as possible as we can. So that there are two threads in the ctx->wait queue. -+ * In this way, we can test if a cqe wakes up two threads at the same time. -+ */ -+ while(!both_wait) { -+ pthread_mutex_lock(&mutex); -+ if (cnt == 2) -+ both_wait = true; -+ pthread_mutex_unlock(&mutex); -+ sleep(1); -+ } -+ -+ sqe = io_uring_get_sqe(&ring); -+ if (!sqe) { -+ fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__); -+ goto err; -+ } -+ -+ io_uring_prep_nop(sqe); -+ -+ ret = io_uring_submit(&ring); -+ if (ret <= 0) { -+ fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret); -+ goto err; -+ } -+ -+ pthread_join(reap_thread0, NULL); -+ pthread_join(reap_thread1, NULL); -+ -+ if ((thread_ret0 && thread_ret0 != -ETIME) || (thread_ret1 && thread_ret1 != -ETIME)) { -+ fprintf(stderr, "%s: thread wait cqe timeout failed: %d %d\n", -+ __FUNCTION__, thread_ret0, thread_ret1); -+ goto err; -+ } -+ -+ return 0; -+err: -+ return 1; -+} -+ -+int main(int argc, char *argv[]) -+{ -+ struct io_uring ring_normal, ring_sq; -+ int ret; -+ -+ if (argc > 1) -+ return 0; -+ -+ ret = io_uring_queue_init(8, &ring_normal, 0); -+ if (ret) { -+ fprintf(stderr, "ring_normal setup failed: %d\n", ret); -+ return 1; -+ } -+ if (!(ring_normal.features & IORING_FEAT_EXT_ARG)) { -+ fprintf(stderr, "feature IORING_FEAT_EXT_ARG not supported.\n"); -+ return 1; -+ } -+ -+ ret = test_return_before_timeout(&ring_normal); -+ if (ret) { -+ fprintf(stderr, "ring_normal: test_return_before_timeout failed\n"); -+ return ret; -+ } -+ -+ ret = test_return_after_timeout(&ring_normal); -+ if (ret) { -+ fprintf(stderr, "ring_normal: test_return_after_timeout failed\n"); -+ return ret; -+ } -+ -+ ret = io_uring_queue_init(8, &ring_sq, IORING_SETUP_SQPOLL); -+ if (ret) { -+ fprintf(stderr, "ring_sq setup failed: %d\n", ret); -+ return 1; -+ } -+ -+ ret = test_return_before_timeout(&ring_sq); -+ if (ret) { -+ fprintf(stderr, "ring_sq: test_return_before_timeout failed\n"); -+ return ret; -+ } -+ -+ ret = test_return_after_timeout(&ring_sq); -+ if (ret) { -+ fprintf(stderr, "ring_sq: test_return_after_timeout failed\n"); -+ return ret; -+ } -+ -+ ret = test_multi_threads_timeout(); -+ if (ret) { -+ fprintf(stderr, "test_multi_threads_timeout failed\n"); -+ return ret; -+ } -+ -+ return 0; -+} --- -1.8.3.1 - diff --git a/1014-liburing-anolis-test-use-a-map-to-define-test-files-devices-we-need.patch b/1014-liburing-anolis-test-use-a-map-to-define-test-files-devices-we-need.patch deleted file mode 100644 index 7bb1e7fdd72b7d6a2b4cfb744c0fae0bef7703cb..0000000000000000000000000000000000000000 --- a/1014-liburing-anolis-test-use-a-map-to-define-test-files-devices-we-need.patch +++ /dev/null @@ -1,68 +0,0 @@ -From c2f5708119a8249feda4e5e283c1e17dc90d4773 Mon Sep 17 00:00:00 2001 -From: Hao Xu -Date: Thu, 25 Feb 2021 16:39:02 +0800 -Subject: [PATCH] test: use a map to define test files / devices we need - -Different tests need different files / devices, use a map to indicate -what each test need. - -Signed-off-by: Hao Xu -Signed-off-by: Jens Axboe ---- - test/config | 2 +- - test/runtests.sh | 13 ++++++------- - 2 files changed, 7 insertions(+), 8 deletions(-) - -diff --git a/test/config b/test/config -index 80a5f467c0c4..d1ea7858ee7a 100644 ---- a/test/config -+++ b/test/config -@@ -1,4 +1,4 @@ - # Define raw test devices (or files) for test cases, if any - # Copy this to config.local, and uncomment + define test files - # --# TEST_FILES="/dev/nvme0n1p2 /data/file" -+declare -A TEST_FILES=() -diff --git a/test/runtests.sh b/test/runtests.sh -index a891f4b91acd..171470bbd5a7 100755 ---- a/test/runtests.sh -+++ b/test/runtests.sh -@@ -6,6 +6,7 @@ RET=0 - TIMEOUT=60 - FAILED="" - MAYBE_FAILED="" -+declare -A TEST_FILES - - do_kmsg="1" - if ! [ $(id -u) = 0 ]; then -@@ -13,10 +14,9 @@ if ! [ $(id -u) = 0 ]; then - fi - - TEST_DIR=$(dirname $0) --TEST_FILES="" - if [ -f "$TEST_DIR/config.local" ]; then - . $TEST_DIR/config.local -- for dev in $TEST_FILES; do -+ for dev in ${TEST_FILES[@]}; do - if [ ! -e "$dev" ]; then - echo "Test file $dev not valid" - exit 1 -@@ -102,11 +102,10 @@ run_test() - } - - for t in $TESTS; do -- run_test $t -- if [ ! -z "$TEST_FILES" ]; then -- for dev in $TEST_FILES; do -- run_test $t $dev -- done -+ if [ ! -n "${TEST_FILES[$t]}" ]; then -+ run_test $t -+ else -+ run_test $t ${TEST_FILES[$t]} - fi - done - --- -1.8.3.1 - diff --git a/1015-liburing-anolis-test-timeout-overflow-don-t-run-on-newer-kernels.patch b/1015-liburing-anolis-test-timeout-overflow-don-t-run-on-newer-kernels.patch deleted file mode 100644 index fea817849486ff6aa6feb10328ec0cfe3ddbffa6..0000000000000000000000000000000000000000 --- a/1015-liburing-anolis-test-timeout-overflow-don-t-run-on-newer-kernels.patch +++ /dev/null @@ -1,70 +0,0 @@ -From 4fe73ec45c51096459971727089a0f0b1f86f926 Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Thu, 13 Aug 2020 18:00:06 -0600 -Subject: [PATCH] test/timeout-overflow: don't run on newer kernels - -It's known to fail with the batched completions, just disable it -on newer kernels. - -Signed-off-by: Jens Axboe -Signed-off-by: Joseph Qi ---- - test/timeout-overflow.c | 17 ++++++++++++++--- - 1 file changed, 14 insertions(+), 3 deletions(-) - -diff --git a/test/timeout-overflow.c b/test/timeout-overflow.c -index 1074e2b..f952f80 100644 ---- a/test/timeout-overflow.c -+++ b/test/timeout-overflow.c -@@ -6,6 +6,7 @@ - #include - #include - #include -+#include - #include - - #include "liburing.h" -@@ -19,19 +20,29 @@ static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec) - ts->tv_nsec = (msec % 1000) * 1000000; - } - --static int check_timeout_support() -+static int check_timeout_support(void) - { - struct io_uring_sqe *sqe; - struct io_uring_cqe *cqe; - struct __kernel_timespec ts; -+ struct io_uring_params p; - struct io_uring ring; - int ret; - -- ret = io_uring_queue_init(8, &ring, 0); -+ memset(&p, 0, sizeof(p)); -+ ret = io_uring_queue_init_params(1, &ring, &p); - if (ret) { - fprintf(stderr, "ring setup failed: %d\n", ret); - return 1; - } -+ -+ /* not really a match, but same kernel added batched completions */ -+ if (p.features & IORING_FEAT_POLL_32BITS) { -+ fprintf(stdout, "Skipping\n"); -+ not_supported = 1; -+ return 0; -+ } -+ - sqe = io_uring_get_sqe(&ring); - msec_to_ts(&ts, TIMEOUT_MSEC); - io_uring_prep_timeout(sqe, &ts, 1, 0); -@@ -74,7 +85,7 @@ err: - * successful after the patch. And req1/req2 will completed successful with - * req3/req4 return -ETIME without this patch! - */ --static int test_timeout_overflow() -+static int test_timeout_overflow(void) - { - struct io_uring_sqe *sqe; - struct io_uring_cqe *cqe; --- -1.8.3.1 - diff --git a/1018-liburing-anolis-adjust-value-for-IORING_ENTER_SQ_SUBMIT_ON_IDLE-to-s.patch b/1018-liburing-anolis-adjust-value-for-IORING_ENTER_SQ_SUBMIT_ON_IDLE-to-s.patch deleted file mode 100644 index b7aab1e1c4c5665e6cdf63a2fd2705212996ccbf..0000000000000000000000000000000000000000 --- a/1018-liburing-anolis-adjust-value-for-IORING_ENTER_SQ_SUBMIT_ON_IDLE-to-s.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 24fa4be977ba0232d6b1abcb8c95a9f65de3a686 Mon Sep 17 00:00:00 2001 -From: Ziyang Zhang -Date: Wed, 30 Nov 2022 15:13:15 +0800 -Subject: [PATCH 1/2] adjust value for IORING_ENTER_SQ_SUBMIT_ON_IDLE to sync - with kernel uapi - -Current value of IORING_ENTER_SQ_SUBMIT_ON_IDLE is too small and it is -in conflict with the upstream IORING_ENTER_REGISTERED_RING. - -Let's adjust value of IORING_ENTER_SQ_SUBMIT_ON_IDLE and prepare for -new io_uring features. - -Signed-off-by: Ziyang Zhang ---- - src/include/liburing/io_uring.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index cacc210..64df61b 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -228,7 +228,7 @@ struct io_cqring_offsets { - #define IORING_ENTER_GETEVENTS (1U << 0) - #define IORING_ENTER_SQ_WAKEUP (1U << 1) - #define IORING_ENTER_EXT_ARG (1U << 3) --#define IORING_ENTER_SQ_SUBMIT_ON_IDLE (1U << 4) -+#define IORING_ENTER_SQ_SUBMIT_ON_IDLE (1U << 31) - - /* - * Passed in for io_uring_setup(2). Copied back with updated info on success --- -2.31.1 - diff --git a/1020-io_uring.h-add-IORING_SETUP_SQE128.patch b/1020-io_uring.h-add-IORING_SETUP_SQE128.patch deleted file mode 100644 index b5e722c2ff2bd3d73976ac24768a73e1bd28cc57..0000000000000000000000000000000000000000 --- a/1020-io_uring.h-add-IORING_SETUP_SQE128.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 01222106355284998baa2e1374401ed0fa013f4c Mon Sep 17 00:00:00 2001 -From: Ziyang Zhang -Date: Fri, 23 Dec 2022 16:44:17 +0800 -Subject: [PATCH 1/7] io_uring.h: add IORING_SETUP_SQE128 - -This asks the kernel to setup a ring with 128-byte SQE entries. May fail -with -EINVAL if the kernel doesn't support this feature. If the kernel -does support the feature, then the ring will support big sqe entries -which some commands may require. - -Signed-off-by: Jens Axboe -Signed-off-by: Ziyang Zhang ---- - src/include/liburing.h | 2 +- - src/include/liburing/io_uring.h | 30 ++++++++++++++++-------------- - 2 files changed, 17 insertions(+), 15 deletions(-) - -diff --git a/src/include/liburing.h b/src/include/liburing.h -index 19dc8b4..5cb3cae 100644 ---- a/src/include/liburing.h -+++ b/src/include/liburing.h -@@ -199,7 +199,7 @@ static inline void io_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd, - sqe->len = len; - sqe->rw_flags = 0; - sqe->user_data = 0; -- sqe->__pad2[0] = sqe->__pad2[1] = sqe->__pad2[2] = 0; -+ sqe->__pad2[0] = sqe->__pad2[1] = 0; - } - - static inline void io_uring_prep_splice(struct io_uring_sqe *sqe, -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index 64df61b..5306dff 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -44,21 +44,22 @@ struct io_uring_sqe { - __u32 splice_flags; - }; - __u64 user_data; /* data to be passed back at completion time */ -+ /* pack this to avoid bogus arm OABI complaints */ - union { -- struct { -- /* pack this to avoid bogus arm OABI complaints */ -- union { -- /* index into fixed buffers, if used */ -- __u16 buf_index; -- /* for grouped buffer selection */ -- __u16 buf_group; -- } __attribute__((packed)); -- /* personality to use, if used */ -- __u16 personality; -- __s32 splice_fd_in; -- }; -- __u64 __pad2[3]; -- }; -+ /* index into fixed buffers, if used */ -+ __u16 buf_index; -+ /* for grouped buffer selection */ -+ __u16 buf_group; -+ } __attribute__((packed)); -+ /* personality to use, if used */ -+ __u16 personality; -+ __s32 splice_fd_in; -+ __u64 __pad2[2]; -+ /* -+ * If the ring is initialized with IORING_SETUP_SQE128, then this field -+ * contains 64-bytes of padding, doubling the size of the SQE. -+ */ -+ __u64 __big_sqe_pad[0]; - }; - - enum { -@@ -95,6 +96,7 @@ enum { - #define IORING_SETUP_CQSIZE (1U << 3) /* app defines CQ size */ - #define IORING_SETUP_CLAMP (1U << 4) /* clamp SQ/CQ ring sizes */ - #define IORING_SETUP_ATTACH_WQ (1U << 5) /* attach to existing wq */ -+#define IORING_SETUP_SQE128 (1U << 10) /* SQEs are 128 byte */ - #define IORING_SETUP_IDLE_US (1U << 30) /* unit of thread_idle is microsecond */ - /* use percpu SQ poll thread */ - #define IORING_SETUP_SQPOLL_PERCPU (1U << 31) --- -2.31.1 - diff --git a/1021-setup-add-basic-support-for-SQE128.patch b/1021-setup-add-basic-support-for-SQE128.patch deleted file mode 100644 index 4635b11a03ea9682b683d796f05e022fa38adcba..0000000000000000000000000000000000000000 --- a/1021-setup-add-basic-support-for-SQE128.patch +++ /dev/null @@ -1,108 +0,0 @@ -From 7061fff6f9e9024702c7775caedd8aa50c792ee4 Mon Sep 17 00:00:00 2001 -From: Ziyang Zhang -Date: Mon, 26 Dec 2022 16:14:44 +0800 -Subject: [PATCH 2/7] setup: add basic support for SQE128 - -Adjust the helpers for getting ring size and knowing how much memory -we need for a ring of a given size, and basic support for knowing -how much to increment a ring when an SQE is allocated. - -Signed-off-by: Jens Axboe -[Ziyang Zhang: backport for anck 5.10] -Signed-off-by: Ziyang Zhang ---- - src/queue.c | 28 +++++++++++++++------------- - src/setup.c | 17 +++++++++++++---- - 2 files changed, 28 insertions(+), 17 deletions(-) - -diff --git a/src/queue.c b/src/queue.c -index d8ee64f..b64885f 100644 ---- a/src/queue.c -+++ b/src/queue.c -@@ -364,18 +364,6 @@ int io_uring_submit_on_idle_and_wait(struct io_uring *ring, unsigned wait_nr) - return __io_uring_submit_and_wait(ring, wait_nr, IORING_ENTER_SQ_SUBMIT_ON_IDLE); - } - --static inline struct io_uring_sqe * --__io_uring_get_sqe(struct io_uring_sq *sq, unsigned int __head) --{ -- unsigned int __next = (sq)->sqe_tail + 1; -- struct io_uring_sqe *__sqe = NULL; -- -- if (__next - __head <= *(sq)->kring_entries) { -- __sqe = &(sq)->sqes[(sq)->sqe_tail & *(sq)->kring_mask]; -- (sq)->sqe_tail = __next; -- } -- return __sqe; --} - - /* - * Return an sqe to fill. Application must later call io_uring_submit() -@@ -387,6 +375,20 @@ __io_uring_get_sqe(struct io_uring_sq *sq, unsigned int __head) - struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring) - { - struct io_uring_sq *sq = &ring->sq; -+ unsigned int head = io_uring_smp_load_acquire(sq->khead); -+ unsigned int next = sq->sqe_tail + 1; -+ int shift = 0; -+ -+ if (ring->flags & IORING_SETUP_SQE128) -+ shift = 1; -+ -+ if (next - head <= *sq->kring_entries) { -+ struct io_uring_sqe *sqe; -+ -+ sqe = &sq->sqes[(sq->sqe_tail & *sq->kring_mask) << shift]; -+ sq->sqe_tail = next; -+ return sqe; -+ } - -- return __io_uring_get_sqe(sq, io_uring_smp_load_acquire(sq->khead)); -+ return NULL; - } -diff --git a/src/setup.c b/src/setup.c -index 260dd2b..570eaed 100644 ---- a/src/setup.c -+++ b/src/setup.c -@@ -59,8 +59,10 @@ static int io_uring_mmap(int fd, struct io_uring_params *p, - sq->kdropped = sq->ring_ptr + p->sq_off.dropped; - sq->array = sq->ring_ptr + p->sq_off.array; - -- size = p->sq_entries * sizeof(struct io_uring_sqe); -- sq->sqes = mmap(0, size, PROT_READ | PROT_WRITE, -+ size = sizeof(struct io_uring_sqe); -+ if (p->flags & IORING_SETUP_SQE128) -+ size += 64; -+ sq->sqes = mmap(0, size * p->sq_entries, PROT_READ | PROT_WRITE, - MAP_SHARED | MAP_POPULATE, fd, - IORING_OFF_SQES); - if (sq->sqes == MAP_FAILED) { -@@ -112,7 +114,10 @@ int io_uring_ring_dontfork(struct io_uring *ring) - if (!ring->sq.ring_ptr || !ring->sq.sqes || !ring->cq.ring_ptr) - return -EINVAL; - -- len = *ring->sq.kring_entries * sizeof(struct io_uring_sqe); -+ len = sizeof(struct io_uring_sqe); -+ if (ring->flags & IORING_SETUP_SQE128) -+ len += 64; -+ len *= *ring->sq.kring_entries; - ret = madvise(ring->sq.sqes, len, MADV_DONTFORK); - if (ret == -1) - return -errno; -@@ -169,8 +174,12 @@ void io_uring_queue_exit(struct io_uring *ring) - { - struct io_uring_sq *sq = &ring->sq; - struct io_uring_cq *cq = &ring->cq; -+ size_t sqe_size; - -- munmap(sq->sqes, *sq->kring_entries * sizeof(struct io_uring_sqe)); -+ sqe_size = sizeof(struct io_uring_sqe); -+ if (ring->flags & IORING_SETUP_SQE128) -+ sqe_size += 64; -+ munmap(sq->sqes, sqe_size * *sq->kring_entries); - io_uring_unmap_rings(sq, cq); - close(ring->ring_fd); - } --- -2.31.1 - diff --git a/1022-test-nop-add-basic-IORING_SETUP_SQE128-tests.patch b/1022-test-nop-add-basic-IORING_SETUP_SQE128-tests.patch deleted file mode 100644 index 550713ee75d0a6c1d2207ac9c5ab43be6a7dd9cb..0000000000000000000000000000000000000000 --- a/1022-test-nop-add-basic-IORING_SETUP_SQE128-tests.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 4b7df34a68054bf2007d193ae3c4ca645e670124 Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Sun, 20 Feb 2022 12:08:42 -0700 -Subject: [PATCH 3/7] test/nop: add basic IORING_SETUP_SQE128 tests - -Just repeats the original test cases, but using a big ring. Assign and -check for user_data never being NULL, which would be a common issue -with mistakes between big and normal SQEs. - -Signed-off-by: Jens Axboe ---- - test/nop.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 57 insertions(+), 7 deletions(-) - -diff --git a/test/nop.c b/test/nop.c -index 82201bd..d477a1b 100644 ---- a/test/nop.c -+++ b/test/nop.c -@@ -12,6 +12,8 @@ - - #include "liburing.h" - -+static int seq; -+ - static int test_single_nop(struct io_uring *ring) - { - struct io_uring_cqe *cqe; -@@ -25,6 +27,7 @@ static int test_single_nop(struct io_uring *ring) - } - - io_uring_prep_nop(sqe); -+ sqe->user_data = ++seq; - - ret = io_uring_submit(ring); - if (ret <= 0) { -@@ -37,7 +40,10 @@ static int test_single_nop(struct io_uring *ring) - fprintf(stderr, "wait completion %d\n", ret); - goto err; - } -- -+ if (!cqe->user_data) { -+ fprintf(stderr, "Unexpected 0 user_data\n"); -+ goto err; -+ } - io_uring_cqe_seen(ring, cqe); - return 0; - err: -@@ -60,6 +66,7 @@ static int test_barrier_nop(struct io_uring *ring) - io_uring_prep_nop(sqe); - if (i == 4) - sqe->flags = IOSQE_IO_DRAIN; -+ sqe->user_data = ++seq; - } - - ret = io_uring_submit(ring); -@@ -77,6 +84,10 @@ static int test_barrier_nop(struct io_uring *ring) - fprintf(stderr, "wait completion %d\n", ret); - goto err; - } -+ if (!cqe->user_data) { -+ fprintf(stderr, "Unexpected 0 user_data\n"); -+ goto err; -+ } - io_uring_cqe_seen(ring, cqe); - } - -@@ -85,15 +96,12 @@ err: - return 1; - } - --int main(int argc, char *argv[]) -+static int test_p(struct io_uring_params *p) - { - struct io_uring ring; - int ret; - -- if (argc > 1) -- return 0; -- -- ret = io_uring_queue_init(8, &ring, 0); -+ ret = io_uring_queue_init_params(8, &ring, p); - if (ret) { - fprintf(stderr, "ring setup failed: %d\n", ret); - return 1; -@@ -102,12 +110,54 @@ int main(int argc, char *argv[]) - ret = test_single_nop(&ring); - if (ret) { - fprintf(stderr, "test_single_nop failed\n"); -- return ret; -+ goto err; - } - - ret = test_barrier_nop(&ring); - if (ret) { - fprintf(stderr, "test_barrier_nop failed\n"); -+ goto err; -+ } -+ -+ io_uring_queue_exit(&ring); -+ return 0; -+err: -+ io_uring_queue_exit(&ring); -+ return ret; -+} -+ -+static int test_normal_ring(void) -+{ -+ struct io_uring_params p = { }; -+ -+ return test_p(&p); -+} -+ -+static int test_big_ring(void) -+{ -+ struct io_uring_params p = { }; -+ -+ p.flags = IORING_SETUP_SQE128; -+ return test_p(&p); -+} -+ -+ -+int main(int argc, char *argv[]) -+{ -+ int ret; -+ -+ if (argc > 1) -+ return 0; -+ -+ ret = test_normal_ring(); -+ if (ret) { -+ fprintf(stderr, "Normal ring test failed\n"); -+ return ret; -+ } -+ -+ ret = test_big_ring(); -+ if (ret) { -+ fprintf(stderr, "Big ring test failed\n"); - return ret; - } - --- -2.31.1 - diff --git a/1023-test-nop-make-less-verbose-and-don-t-fail-on-older-k.patch b/1023-test-nop-make-less-verbose-and-don-t-fail-on-older-k.patch deleted file mode 100644 index a1f93a3a452ff99cd3fb3ae66731587018e066eb..0000000000000000000000000000000000000000 --- a/1023-test-nop-make-less-verbose-and-don-t-fail-on-older-k.patch +++ /dev/null @@ -1,30 +0,0 @@ -From e5b7ad1f5d25d183346ac13f5714310972d5f4a2 Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Fri, 13 May 2022 11:40:55 -0600 -Subject: [PATCH 4/7] test/nop: make less verbose and don't fail on older - kernels - -Signed-off-by: Jens Axboe -Signed-off-by: Ziyang Zhang ---- - test/nop.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/test/nop.c b/test/nop.c -index d477a1b..bba7caa 100644 ---- a/test/nop.c -+++ b/test/nop.c -@@ -103,6 +103,10 @@ static int test_p(struct io_uring_params *p) - - ret = io_uring_queue_init_params(8, &ring, p); - if (ret) { -+ if (ret == -EINVAL) { -+ fprintf(stdout, "IORING_SETUP_SQE128 not supported\n"); -+ return 0; -+ } - fprintf(stderr, "ring setup failed: %d\n", ret); - return 1; - } --- -2.31.1 - diff --git a/1024-io_uring.h-support-IORING_OP_URING_CMD.patch b/1024-io_uring.h-support-IORING_OP_URING_CMD.patch deleted file mode 100644 index fe7f2cf5fe5524397704959efd209a2e7817f4d7..0000000000000000000000000000000000000000 --- a/1024-io_uring.h-support-IORING_OP_URING_CMD.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 28ddb2fd15d69e043ed89b63db44907a8fad0eb8 Mon Sep 17 00:00:00 2001 -From: Ziyang Zhang -Date: Mon, 26 Dec 2022 15:59:26 +0800 -Subject: [PATCH 5/7] io_uring.h: support IORING_OP_URING_CMD - -Signed-off-by: Ziyang Zhang ---- - src/include/liburing/io_uring.h | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index 5306dff..0af8bc4 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -136,6 +136,7 @@ enum { - IORING_OP_PROVIDE_BUFFERS, - IORING_OP_REMOVE_BUFFERS, - IORING_OP_TEE, -+ IORING_OP_URING_CMD, - - /* this goes last, obviously */ - IORING_OP_LAST, --- -2.31.1 - diff --git a/1025-man-io_uring_setup.2-document-IORING_SETUP_SQE128-fl.patch b/1025-man-io_uring_setup.2-document-IORING_SETUP_SQE128-fl.patch deleted file mode 100644 index 0bc4a6d8075ab780ced0e20fa8f157b4c8037b50..0000000000000000000000000000000000000000 --- a/1025-man-io_uring_setup.2-document-IORING_SETUP_SQE128-fl.patch +++ /dev/null @@ -1,32 +0,0 @@ -From f2d54142ad04900c7768fcf858fad498e3e7ad6a Mon Sep 17 00:00:00 2001 -From: Jens Axboe -Date: Mon, 16 May 2022 20:14:00 -0600 -Subject: [PATCH 6/7] man/io_uring_setup.2: document IORING_SETUP_SQE128 flag - -Signed-off-by: Jens Axboe -[Ziyang Zhang: note that it is used for uring-cmd by ublk] -Signed-off-by: Ziyang Zhang ---- - man/io_uring_setup.2 | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/man/io_uring_setup.2 b/man/io_uring_setup.2 -index a2a9072..c0da6cd 100644 ---- a/man/io_uring_setup.2 -+++ b/man/io_uring_setup.2 -@@ -149,6 +149,12 @@ entries. The value must be greater than - .IR entries , - and may be rounded up to the next power-of-two. - .TP -+.B IORING_SETUP_SQE128 -+If set, io_uring will use 128-byte SQEs rather than the normal 64-byte sized -+variant. This is a requirement for using -+.B IORING_OP_URING_CMD -+by ublk. -+.TP - .B IORING_SETUP_IDLE_US - If this flag is set, the unit of - .I sq_thread_idle --- -2.31.1 - diff --git a/1026-io_uring.h-Add-missing-fields-for-uring_cmd-in-struc.patch b/1026-io_uring.h-Add-missing-fields-for-uring_cmd-in-struc.patch deleted file mode 100644 index 7fe236ebc8683db14442639aa7d1a0f2735cf6c4..0000000000000000000000000000000000000000 --- a/1026-io_uring.h-Add-missing-fields-for-uring_cmd-in-struc.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 7816dac311226fb0d5e6a0cc2b993f0e74c62744 Mon Sep 17 00:00:00 2001 -From: Ziyang Zhang -Date: Fri, 13 Jan 2023 17:06:38 +0800 -Subject: [PATCH 7/7] io_uring.h: Add missing fields for uring_cmd in struct - io_uring_sqe - -Signed-off-by: Ziyang Zhang ---- - src/include/liburing/io_uring.h | 15 +++++++++------ - 1 file changed, 9 insertions(+), 6 deletions(-) - -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index 0af8bc4..1970201 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -22,6 +22,7 @@ struct io_uring_sqe { - union { - __u64 off; /* offset into file */ - __u64 addr2; -+ __u32 cmd_op; - }; - union { - __u64 addr; /* pointer to buffer or iovecs */ -@@ -54,12 +55,14 @@ struct io_uring_sqe { - /* personality to use, if used */ - __u16 personality; - __s32 splice_fd_in; -- __u64 __pad2[2]; -- /* -- * If the ring is initialized with IORING_SETUP_SQE128, then this field -- * contains 64-bytes of padding, doubling the size of the SQE. -- */ -- __u64 __big_sqe_pad[0]; -+ union { -+ __u64 __pad2[2]; -+ /* -+ * If the ring is initialized with IORING_SETUP_SQE128, then -+ * this field is used for 80 bytes of arbitrary command data -+ */ -+ __u8 cmd[0]; -+ }; - }; - - enum { --- -2.31.1 - diff --git a/1027-io_uring.h-fix-IORING_OP_URING_CMD-incompatible-issu.patch b/1027-io_uring.h-fix-IORING_OP_URING_CMD-incompatible-issu.patch deleted file mode 100644 index 1254c25402a9062f6002e413f5f481ca25f37e4e..0000000000000000000000000000000000000000 --- a/1027-io_uring.h-fix-IORING_OP_URING_CMD-incompatible-issu.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0db609d820dd6ef52ac73f7297038a9872eb3375 Mon Sep 17 00:00:00 2001 -From: Ziyang Zhang -Date: Mon, 17 Apr 2023 11:14:54 +0800 -Subject: [PATCH] io_uring.h: fix IORING_OP_URING_CMD incompatible issue - -We need to add 12 new io_uring operation codes, such as IORING_OP_SHUTDOWN, -though their actual functionality are not supportted yet. With this action, -the IORING_OP_URING_CMD incompatible issue will go. - -Acked-by: Xiaoguang Wang -Signed-off-by: Ziyang Zhang ---- - src/include/liburing/io_uring.h | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h -index 1970201..ec86d17 100644 ---- a/src/include/liburing/io_uring.h -+++ b/src/include/liburing/io_uring.h -@@ -139,6 +139,18 @@ enum { - IORING_OP_PROVIDE_BUFFERS, - IORING_OP_REMOVE_BUFFERS, - IORING_OP_TEE, -+ IORING_OP_SHUTDOWN, -+ IORING_OP_RENAMEAT, -+ IORING_OP_UNLINKAT, -+ IORING_OP_MKDIRAT, -+ IORING_OP_SYMLINKAT, -+ IORING_OP_LINKAT, -+ IORING_OP_MSG_RING, -+ IORING_OP_FSETXATTR, -+ IORING_OP_SETXATTR, -+ IORING_OP_FGETXATTR, -+ IORING_OP_GETXATTR, -+ IORING_OP_SOCKET, - IORING_OP_URING_CMD, - - /* this goes last, obviously */ --- -2.31.1 - diff --git a/liburing-1.0.7.tar.bz2 b/liburing-1.0.7.tar.bz2 deleted file mode 100644 index f893e56ae0f7ee911c6c624777c1649e5a547f81..0000000000000000000000000000000000000000 Binary files a/liburing-1.0.7.tar.bz2 and /dev/null differ diff --git a/liburing-2.3.tar.bz2 b/liburing-2.3.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..d2a931f77580ea593d79ae0c12dfb71faf001e55 Binary files /dev/null and b/liburing-2.3.tar.bz2 differ diff --git a/liburing-always-build-with-fPIC.patch b/liburing-always-build-with-fPIC.patch deleted file mode 100644 index 6daa3d00b3cf338fe4533a5aad4d6439c7d09ae0..0000000000000000000000000000000000000000 --- a/liburing-always-build-with-fPIC.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/Makefile b/src/Makefile -index 44a95ad..6fd050d 100644 ---- a/src/Makefile -+++ b/src/Makefile -@@ -4,9 +4,9 @@ libdir ?= $(prefix)/lib - libdevdir ?= $(prefix)/lib - - CFLAGS ?= -g -fomit-frame-pointer -O2 --override CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare\ -+override CFLAGS += -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -fPIC\ - -Iinclude/ -include ../config-host.h --SO_CFLAGS=-fPIC $(CFLAGS) -+SO_CFLAGS=$(CFLAGS) - L_CFLAGS=$(CFLAGS) - LINK_FLAGS= - LINK_FLAGS+=$(LDFLAGS) diff --git a/liburing.spec b/liburing.spec index 82e25677d2d2d2224cb59af3927823d38ac8648b..3d50b427ad387563be106699b09a2e6fd1f2659e 100644 --- a/liburing.spec +++ b/liburing.spec @@ -1,42 +1,22 @@ -%define anolis_release .0.4 +%define anolis_release 2 Name: liburing -Version: 1.0.7 -Release: 3%{anolis_release}%{?dist} +Version: 2.3 +Release: %{anolis_release}%{?dist} Summary: Linux-native io_uring I/O access library License: LGPLv2+ Source: %{name}-%{version}.tar.bz2 URL: http://brick.kernel.dk/snaps/%{name}-%{version}.tar.bz2 BuildRequires: gcc -Patch0: liburing-always-build-with-fPIC.patch # Begin: Anolis customized patches -Patch1001: 1001-liburing-anolis-Add-percpu-io-sq-thread-support.patch -Patch1002: 1002-liburing-anolis-Revert-Make-the-liburing-header-files-again-compatib.patch -Patch1003: 1003-liburing-anolis-Revert-src-include-liburing-barrier.h-Restore-clang-.patch -Patch1004: 1004-liburing-anolis-Revert-src-include-liburing-barrier.h-Use-C11-atomic.patch -Patch1005: 1005-liburing-anolis-sq_ring_needs_enter-revert-change-to-only-enter-if-s.patch -Patch1006: 1006-liburing-anolis-io_uring.h-update-with-5.11-pending-copy.patch -Patch1007: 1007-liburing-anolis-Include-features-in-struct-io_uring.patch -Patch1008: 1008-liburing-anolis-Add-__sys_io_uring_enter2.patch -Patch1009: 1009-liburing-anolis-Add-wrapper-for-__io_uring_get_cqe.patch -Patch1010: 1010-liburing-anolis-Use-IORING_ENTER_GETEVENTS_TIMEOUT-if-available.patch -Patch1011: 1011-liburing-anolis-Update-SIG_IS_DATA-to-modified-kernel-API.patch -Patch1012: 1012-liburing-anolis-Rename-SIG_IS_DATA-EXT_ARG.patch -Patch1013: 1013-liburing-anolis-test-timeout-new-test-for-timeout-feature.patch -Patch1014: 1014-liburing-anolis-test-use-a-map-to-define-test-files-devices-we-need.patch -Patch1015: 1015-liburing-anolis-test-timeout-overflow-don-t-run-on-newer-kernels.patch -Patch1016: 1016-liburing-anolis-support-us-granularity-of-io_sq_thread_idle.patch -Patch1017: 1017-liburing-anolis-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch -Patch1018: 1018-liburing-anolis-adjust-value-for-IORING_ENTER_SQ_SUBMIT_ON_IDLE-to-s.patch -Patch1019: 1019-liburing-anolis-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch -Patch1020: 1020-io_uring.h-add-IORING_SETUP_SQE128.patch -Patch1021: 1021-setup-add-basic-support-for-SQE128.patch -Patch1022: 1022-test-nop-add-basic-IORING_SETUP_SQE128-tests.patch -Patch1023: 1023-test-nop-make-less-verbose-and-don-t-fail-on-older-k.patch -Patch1024: 1024-io_uring.h-support-IORING_OP_URING_CMD.patch -Patch1025: 1025-man-io_uring_setup.2-document-IORING_SETUP_SQE128-fl.patch -Patch1026: 1026-io_uring.h-Add-missing-fields-for-uring_cmd-in-struc.patch -Patch1027: 1027-io_uring.h-fix-IORING_OP_URING_CMD-incompatible-issu.patch +Patch1001: 1001-Add-percpu-io-sq-thread-support.patch +Patch1002: 1002-support-us-granularity-of-io_sq_thread_idle.patch +Patch1003: 1003-add-IORING_ENTER_SQ_SUBMIT_ON_IDLE-flag.patch +Patch1004: 1004-Add-a-test-for-sqpoll-sq_thread_idle_us-mode.patch +Patch1005: 1005-test-io_uring_passthrough-skip-if-kernel-doesn-t-sup.patch +Patch1006: 1006-test-io_uring_passthrough-fix-iopoll-test.patch +Patch1007: 1007-test-io_uring_passthrough-cleanup-invalid-submission.patch +Patch1008: 1008-test-io_uring_passthrough-skip-test-if-bit-sqe-cqe-s.patch # End: Anolis customized patches %description @@ -74,8 +54,13 @@ for the Linux-native io_uring. %{_libdir}/liburing.a %{_libdir}/pkgconfig/* %{_mandir}/man2/* +%{_mandir}/man3/* +%{_mandir}/man7/* %changelog +* Tue Jun 20 2023 Joseph Qi - 2.3-2 +- update to liburing-2.3 to io_uring_passthrough + * Tue Apr 18 2023 Ziyang Zhang - 1.0.7-3.0.4 - fix IORING_OP_URING_CMD incompatible issue