public inbox for [email protected]
 help / color / mirror / Atom feed
From: Stefano Garzarella <[email protected]>
To: Ye Bin <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCH] io_uring: Remove unneeded NULL check before free
Date: Thu, 24 Sep 2020 11:59:33 +0200	[thread overview]
Message-ID: <20200924095933.kqi6rblp65q5lmer@steredhat> (raw)
In-Reply-To: <[email protected]>

Hi,
thanks for the patch, but as explained in some comments in the code,
it's seems faster to do the check and avoid to call kfree() in the
critical data path.

On Thu, Sep 24, 2020 at 09:36:06AM +0800, Ye Bin wrote:
> Fixes coccicheck warnig:
> fs//io_uring.c:5775:4-9: WARNING: NULL check before some freeing
> functions is not needed.
> fs//io_uring.c:1617:2-7: WARNING: NULL check before some freeing
> functions is not needed.
> fs//io_uring.c:3291:2-7: WARNING: NULL check before some freeing
> functions is not needed.
> fs//io_uring.c:3398:2-7: WARNING: NULL check before some freeing
> functions is not needed.
> 
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Ye Bin <[email protected]>
> ---
>  fs/io_uring.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 815be15c2aee..23f99ffbb480 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -1613,8 +1613,7 @@ static bool io_dismantle_req(struct io_kiocb *req)
>  {
>  	io_clean_op(req);
>  
> -	if (req->async_data)
> -		kfree(req->async_data);
> +	kfree(req->async_data);
>  	if (req->file)
>  		io_put_file(req, req->file, (req->flags & REQ_F_FIXED_FILE));
>  
> @@ -3287,8 +3286,7 @@ static int io_read(struct io_kiocb *req, bool force_nonblock,
>  	ret = 0;
>  out_free:
>  	/* it's reportedly faster than delegating the null check to kfree() */
For example here ^

> -	if (iovec)
> -		kfree(iovec);
> +	kfree(iovec);
>  	return ret;
>  }
>  
> @@ -3394,8 +3392,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock,
>  	}
>  out_free:
>  	/* it's reportedly faster than delegating the null check to kfree() */
> -	if (iovec)
> -		kfree(iovec);
> +	kfree(iovec);
>  	return ret;
>  }
>  
> @@ -5771,8 +5768,7 @@ static void __io_clean_op(struct io_kiocb *req)
>  		case IORING_OP_WRITE_FIXED:
>  		case IORING_OP_WRITE: {
>  			struct io_async_rw *io = req->async_data;
> -			if (io->free_iovec)
> -				kfree(io->free_iovec);
> +			kfree(io->free_iovec);
>  			break;
>  			}
>  		case IORING_OP_RECVMSG:
> -- 
> 2.16.2.dirty
> 

Thanks,
Stefano


      reply	other threads:[~2020-09-24  9:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-24  1:36 [PATCH] io_uring: Remove unneeded NULL check before free Ye Bin
2020-09-24  9:59 ` Stefano Garzarella [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200924095933.kqi6rblp65q5lmer@steredhat \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox