Misc 5.13 fixes
Jens Axboe
maintainerv2 cover Misc 5.13 fixes
Hi,
#1 disables multishot requests for double waitqueue users for now, it's got a few corner cases that need hashing out.
#2 is a prep patch for #3, which ties the ->apoll lifetime with that of the request instead of keeping it seperate. That's more logical and makes it handled more like other dynamically allocated items.
fs/io_uring.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-)
Since v1:
- Turn double wait multishot into single-shot. The application logic won't change for that, it'll just be a bit less efficient as it'll require a re-arm for each trigger. It effectively just turns multishot into single shot mode for double wait use cases (which are rare).
- Add flag checking helper and make the io_clean_op() call conditional again.
Signature · 1 line
Jens Axboe
Jens Axboe
maintainerPATCH v2 1/3 io_uring: disable multishot poll for double poll add cases
The re-add handling isn't correct for the multi wait case, so let's just disable it for now explicitly until we can get that sorted out. This just turns it into a one-shot request. Since we pass back whether or not a poll request terminates in multishot mode on completion, this should not break properly behaving applications that check for IORING_CQE_F_MORE on completion.
--- fs/io_uring.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/io_uring.c +6 -0
@@ -4976,6 +4976,12 @@ static void __io_queue_proc(struct io_poll_iocb *poll, struct io_poll_table *pt, pt->error = -EINVAL ;return ; } +/* +* Can't handle multishot for double wait for now, turn it +* into one-shot mode. +*/ +if (!(req->poll.events &EPOLLONESHOT )) + req->poll.events |=EPOLLONESHOT ;/* double add on the same waitqueue head, ignore */ if (poll->head == head)return ;
Signature · 1 line
2.31.1
Jens Axboe
maintainerPATCH v2 2/3 io_uring: put flag checking for needing req cleanup in one spot
In reply to Jens AxboeWe have this in two spots right now, which is a bit fragile. In preparation for moving REQ_F_POLLED cleanup into the same spot, move the check into a separate helper so we only have it once.
--- fs/io_uring.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
fs/io_uring.c +7 -4
@@ -1598,10 +1598,15 @@ static void io_req_complete_post(struct io_kiocb *req, long res, } } +static inline bool io_req_needs_clean (struct io_kiocb *req) +{ +return req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_NEED_CLEANUP ); +} +static void io_req_complete_state (struct io_kiocb *req,long res,unsigned int cflags) { -if (req->flags & (REQ_F_NEED_CLEANUP |REQ_F_BUFFER_SELECTED )) +if (io_req_needs_clean (req))io_clean_op (req); req->result = res; req->compl.cflags = cflags;
@@ -1713,10 +1718,8 @@ static void io_dismantle_req(struct io_kiocb *req)if (!(flags &REQ_F_FIXED_FILE ))io_put_file (req->file); -if (flags & (REQ_F_NEED_CLEANUP |REQ_F_BUFFER_SELECTED | -REQ_F_INFLIGHT )) { +if (io_req_needs_clean (req) || (req->flags &REQ_F_INFLIGHT )) {io_clean_op (req); -if (req->flags &REQ_F_INFLIGHT ) {struct io_uring_task *tctx = req->task->io_uring;
Signature · 1 line
2.31.1
Re: [PATCH 2/3] io_uring: put flag checking for needing req cleanup in one spot
Quoted 3 lines · Jens Axboe
We have this in two spots right now, which is a bit fragile. In preparation for moving
REQ_F_POLLEDcleanup into the same spot, move the check into a separate helper so we only have it once.
Perfect, others look good to me as well
Quoted 40 lines
Signed-off-by Jens Axboe <[email protected]>--- fs/io_uring.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)fs/io_uring.c +7
-4@@ -1598,10 +1598,15 @@ static void io_req_complete_post(struct io_kiocb *req, long res, } } +static inline bool io_req_needs_clean (struct io_kiocb *req) +{ +return req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_NEED_CLEANUP ); +} +static void io_req_complete_state (struct io_kiocb *req,long res,unsigned int cflags) { -if (req->flags & (REQ_F_NEED_CLEANUP |REQ_F_BUFFER_SELECTED )) +if (io_req_needs_clean (req))io_clean_op (req); req->result = res; req->compl.cflags = cflags;@@ -1713,10 +1718,8 @@ static void io_dismantle_req(struct io_kiocb *req)if (!(flags &REQ_F_FIXED_FILE ))io_put_file (req->file); -if (flags & (REQ_F_NEED_CLEANUP |REQ_F_BUFFER_SELECTED | -REQ_F_INFLIGHT )) { +if (io_req_needs_clean (req) || (req->flags &REQ_F_INFLIGHT )) {io_clean_op (req); -if (req->flags &REQ_F_INFLIGHT ) {struct io_uring_task *tctx = req->task->io_uring;
Signature · 1 line
Pavel Begunkov
Jens Axboe
maintainerPATCH v2 3/3 io_uring: tie req->apoll to request lifetime
In reply to Jens AxboeWe manage these separately right now, just tie it to the request lifetime and make it be part of the usual REQ_F_NEED_CLEANUP logic.
--- fs/io_uring.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
fs/io_uring.c +7 -10
@@ -1600,7 +1600,8 @@ static void io_req_complete_post(struct io_kiocb *req, long res,static inline bool io_req_needs_clean (struct io_kiocb *req) { -return req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_NEED_CLEANUP ); +return req->flags & (REQ_F_BUFFER_SELECTED |REQ_F_NEED_CLEANUP | +REQ_F_POLLED ); } static void io_req_complete_state(struct io_kiocb *req, long res,
@@ -5038,9 +5039,6 @@ static void io_async_task_func(struct callback_head *cb)__io_req_task_submit (req); else io_req_complete_failed(req, -ECANCELED); - -kfree (apoll->double_poll); -kfree (apoll); } static int io_async_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
@@ -5156,8 +5154,6 @@ static bool io_arm_poll_handler(struct io_kiocb *req)if (ret || ipt.error) {io_poll_remove_double (req);spin_unlock_irq (&ctx->completion_lock); -kfree (apoll->double_poll); -kfree (apoll);return false; }spin_unlock_irq (&ctx->completion_lock);
@@ -5195,12 +5191,8 @@ static bool io_poll_remove_waitqs(struct io_kiocb *req) do_complete =__io_poll_remove_one (req,io_poll_get_single (req), true);if (req->opcode !=IORING_OP_POLL_ADD && do_complete) { -struct async_poll *apoll = req->apoll; -/* non-poll requests have submit ref still */ req_ref_put (req); -kfree (apoll->double_poll); -kfree (apoll); }return do_complete; }
@@ -6054,6 +6046,11 @@ static void io_clean_op(struct io_kiocb *req) } req->flags &= ~REQ_F_NEED_CLEANUP ; } +if ((req->flags &REQ_F_POLLED ) && req->apoll) { +kfree (req->apoll->double_poll); +kfree (req->apoll); + req->apoll =NULL ; + } }static int io_issue_sqe (struct io_kiocb *req,unsigned int issue_flags)
Signature · 1 line
2.31.1