diff mbox series

[for-next,v3,1/9] io_uring: io_req_complete_post should defer if available

Message ID 20221124093559.3780686-2-dylany@meta.com (mailing list archive)
State New
Headers show
Series io_uring: batch multishot completions | expand

Commit Message

Dylan Yudaken Nov. 24, 2022, 9:35 a.m. UTC
For consistency always defer completion if specified in the issue flags.

Signed-off-by: Dylan Yudaken <dylany@meta.com>
---
 io_uring/io_uring.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Pavel Begunkov Nov. 24, 2022, 3:56 p.m. UTC | #1
On 11/24/22 09:35, Dylan Yudaken wrote:
> For consistency always defer completion if specified in the issue flags.
> 
> Signed-off-by: Dylan Yudaken <dylany@meta.com>
> ---
>   io_uring/io_uring.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
> index cc27413129fc..ec23ebb63489 100644
> --- a/io_uring/io_uring.c
> +++ b/io_uring/io_uring.c
> @@ -852,7 +852,9 @@ static void __io_req_complete_post(struct io_kiocb *req)
>   
>   void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
>   {
> -	if (!(issue_flags & IO_URING_F_UNLOCKED) ||
> +	if (issue_flags & IO_URING_F_COMPLETE_DEFER) {
> +		io_req_complete_defer(req);
> +	} else if (!(issue_flags & IO_URING_F_UNLOCKED) ||
>   	    !(req->ctx->flags & IORING_SETUP_IOPOLL)) {
>   		__io_req_complete_post(req);
>   	} else {

I think it's better to leave it and not impose a second meaning
onto it. We can explicitly call io_req_complete_defer() in all
places that require it, maybe with a new helper like io_req_complete()
if needed.
Dylan Yudaken Nov. 25, 2022, 9:26 a.m. UTC | #2
On Thu, 2022-11-24 at 15:56 +0000, Pavel Begunkov wrote:
> On 11/24/22 09:35, Dylan Yudaken wrote:
> > For consistency always defer completion if specified in the issue
> > flags.
> > 
> > Signed-off-by: Dylan Yudaken <dylany@meta.com>
> > ---
> >   io_uring/io_uring.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
> > index cc27413129fc..ec23ebb63489 100644
> > --- a/io_uring/io_uring.c
> > +++ b/io_uring/io_uring.c
> > @@ -852,7 +852,9 @@ static void __io_req_complete_post(struct
> > io_kiocb *req)
> >   
> >   void io_req_complete_post(struct io_kiocb *req, unsigned
> > issue_flags)
> >   {
> > -       if (!(issue_flags & IO_URING_F_UNLOCKED) ||
> > +       if (issue_flags & IO_URING_F_COMPLETE_DEFER) {
> > +               io_req_complete_defer(req);
> > +       } else if (!(issue_flags & IO_URING_F_UNLOCKED) ||
> >             !(req->ctx->flags & IORING_SETUP_IOPOLL)) {
> >                 __io_req_complete_post(req);
> >         } else {
> 
> I think it's better to leave it and not impose a second meaning
> onto it. We can explicitly call io_req_complete_defer() in all
> places that require it, maybe with a new helper like
> io_req_complete()
> if needed.
> 

I think you may be right - I'll give it a try and send some clean up
patches.

Dylan
diff mbox series

Patch

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index cc27413129fc..ec23ebb63489 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -852,7 +852,9 @@  static void __io_req_complete_post(struct io_kiocb *req)
 
 void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
 {
-	if (!(issue_flags & IO_URING_F_UNLOCKED) ||
+	if (issue_flags & IO_URING_F_COMPLETE_DEFER) {
+		io_req_complete_defer(req);
+	} else if (!(issue_flags & IO_URING_F_UNLOCKED) ||
 	    !(req->ctx->flags & IORING_SETUP_IOPOLL)) {
 		__io_req_complete_post(req);
 	} else {