diff mbox series

[PATCHv5,01/11] io_uring/rsrc: remove redundant check for valid imu

Message ID 20250224213116.3509093-2-kbusch@meta.com (mailing list archive)
State New
Headers show
Series ublk zero copy support | expand

Commit Message

Keith Busch Feb. 24, 2025, 9:31 p.m. UTC
From: Keith Busch <kbusch@kernel.org>

The only caller to io_buffer_unmap already checks if the node's buf is
not null, so no need to check again.

Signed-off-by: Keith Busch <kbusch@kernel.org>
---
 io_uring/rsrc.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

Comments

Ming Lei Feb. 25, 2025, 8:37 a.m. UTC | #1
On Mon, Feb 24, 2025 at 01:31:06PM -0800, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> The only caller to io_buffer_unmap already checks if the node's buf is
> not null, so no need to check again.
> 
> Signed-off-by: Keith Busch <kbusch@kernel.org>

Reviewed-by: Ming Lei <ming.lei@redhat.com>


Thanks,
Ming
Pavel Begunkov Feb. 25, 2025, 1:13 p.m. UTC | #2
On 2/24/25 21:31, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> The only caller to io_buffer_unmap already checks if the node's buf is
> not null, so no need to check again.

Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>

> 
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
>   io_uring/rsrc.c | 19 ++++++++-----------
>   1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index 20b884c84e55f..efef29352dcfb 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -103,19 +103,16 @@ int io_buffer_validate(struct iovec *iov)
>   
>   static void io_buffer_unmap(struct io_ring_ctx *ctx, struct io_rsrc_node *node)
>   {
> +	struct io_mapped_ubuf *imu = node->buf;
>   	unsigned int i;
>   
> -	if (node->buf) {
> -		struct io_mapped_ubuf *imu = node->buf;
> -
> -		if (!refcount_dec_and_test(&imu->refs))
> -			return;
> -		for (i = 0; i < imu->nr_bvecs; i++)
> -			unpin_user_page(imu->bvec[i].bv_page);
> -		if (imu->acct_pages)
> -			io_unaccount_mem(ctx, imu->acct_pages);
> -		kvfree(imu);
> -	}
> +	if (!refcount_dec_and_test(&imu->refs))
> +		return;
> +	for (i = 0; i < imu->nr_bvecs; i++)
> +		unpin_user_page(imu->bvec[i].bv_page);
> +	if (imu->acct_pages)
> +		io_unaccount_mem(ctx, imu->acct_pages);
> +	kvfree(imu);
>   }
>   
>   struct io_rsrc_node *io_rsrc_node_alloc(int type)
diff mbox series

Patch

diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
index 20b884c84e55f..efef29352dcfb 100644
--- a/io_uring/rsrc.c
+++ b/io_uring/rsrc.c
@@ -103,19 +103,16 @@  int io_buffer_validate(struct iovec *iov)
 
 static void io_buffer_unmap(struct io_ring_ctx *ctx, struct io_rsrc_node *node)
 {
+	struct io_mapped_ubuf *imu = node->buf;
 	unsigned int i;
 
-	if (node->buf) {
-		struct io_mapped_ubuf *imu = node->buf;
-
-		if (!refcount_dec_and_test(&imu->refs))
-			return;
-		for (i = 0; i < imu->nr_bvecs; i++)
-			unpin_user_page(imu->bvec[i].bv_page);
-		if (imu->acct_pages)
-			io_unaccount_mem(ctx, imu->acct_pages);
-		kvfree(imu);
-	}
+	if (!refcount_dec_and_test(&imu->refs))
+		return;
+	for (i = 0; i < imu->nr_bvecs; i++)
+		unpin_user_page(imu->bvec[i].bv_page);
+	if (imu->acct_pages)
+		io_unaccount_mem(ctx, imu->acct_pages);
+	kvfree(imu);
 }
 
 struct io_rsrc_node *io_rsrc_node_alloc(int type)