From 065184a2030620332103622978b7840b95cfcf9b Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Tue, 7 Oct 2025 19:52:48 +0800 Subject: [PATCH] batch ioevent_uring_submit for RDMA network --- src/ioevent.c | 9 ++++++--- src/ioevent_loop.c | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/ioevent.c b/src/ioevent.c index 44d5c04..c6552b5 100644 --- a/src/ioevent.c +++ b/src/ioevent.c @@ -138,7 +138,8 @@ int ioevent_attach(IOEventPoller *ioevent, const int fd, } io_uring_prep_poll_multishot(sqe, fd, e | ioevent->extra_events); sqe->user_data = (long)data; - return ioevent_uring_submit(ioevent); + ioevent->submit_count++; + return 0; #elif IOEVENT_USE_KQUEUE struct kevent ev[2]; int n = 0; @@ -174,7 +175,8 @@ int ioevent_modify(IOEventPoller *ioevent, const int fd, io_uring_prep_poll_update(sqe, sqe->user_data, sqe->user_data, e | ioevent->extra_events, IORING_POLL_UPDATE_EVENTS); sqe->user_data = (long)data; - return ioevent_uring_submit(ioevent); + ioevent->submit_count++; + return 0; #elif IOEVENT_USE_KQUEUE struct kevent ev[2]; int result; @@ -219,7 +221,8 @@ int ioevent_detach(IOEventPoller *ioevent, const int fd) io_uring_prep_cancel_fd(sqe, fd, 0); /* set sqe->flags MUST after io_uring_prep_xxx */ sqe->flags = IOSQE_CQE_SKIP_SUCCESS; - return ioevent_uring_submit(ioevent); + ioevent->submit_count++; + return 0; #elif IOEVENT_USE_KQUEUE struct kevent ev[1]; int r, w; diff --git a/src/ioevent_loop.c b/src/ioevent_loop.c index e062029..d34e682 100644 --- a/src/ioevent_loop.c +++ b/src/ioevent_loop.c @@ -201,6 +201,17 @@ int ioevent_loop(struct nio_thread_data *thread_data, sched_pull = true; #endif +#if IOEVENT_USE_URING + if (thread_data->ev_puller.submit_count > 0) { + if ((result=ioevent_uring_submit(&thread_data->ev_puller)) != 0) { + logError("file: "__FILE__", line: %d, " + "io_uring_submit fail, errno: %d, error info: %s", + __LINE__, result, STRERROR(result)); + return result; + } + } +#endif + if (sched_pull) { if ((result=ioevent_process(&thread_data->ev_puller)) != 0) { return result; @@ -258,17 +269,6 @@ int ioevent_loop(struct nio_thread_data *thread_data, if (thread_data->thread_loop_callback != NULL) { thread_data->thread_loop_callback(thread_data); } - -#if IOEVENT_USE_URING - if (thread_data->ev_puller.submit_count > 0) { - if ((result=ioevent_uring_submit(&thread_data->ev_puller)) != 0) { - logError("file: "__FILE__", line: %d, " - "io_uring_submit fail, errno: %d, error info: %s", - __LINE__, result, STRERROR(result)); - return result; - } - } -#endif } return 0;