public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ublk: remove unnecessary ubq checks
@ 2025-04-16 17:01 Caleb Sander Mateos
  2025-04-16 19:47 ` Uday Shankar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Caleb Sander Mateos @ 2025-04-16 17:01 UTC (permalink / raw)
  To: Ming Lei, Jens Axboe; +Cc: Caleb Sander Mateos, linux-block, linux-kernel

ublk_init_queues() ensures that all nr_hw_queues queues are initialized,
with each ublk_queue's q_id set to its index. And ublk_init_queues() is
called before ublk_add_chdev(), which creates the cdev. Is is therefore
impossible for the !ubq || ub_cmd->q_id != ubq->q_id condition to hit in
__ublk_ch_uring_cmd(). Remove it to avoids some branches in the I/O path.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 drivers/block/ublk_drv.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index cdb1543fa4a9..bc86231f5e27 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1947,13 +1947,10 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
 
 	if (ub_cmd->q_id >= ub->dev_info.nr_hw_queues)
 		goto out;
 
 	ubq = ublk_get_queue(ub, ub_cmd->q_id);
-	if (!ubq || ub_cmd->q_id != ubq->q_id)
-		goto out;
-
 	if (ubq->ubq_daemon && ubq->ubq_daemon != current)
 		goto out;
 
 	if (tag >= ubq->q_depth)
 		goto out;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ublk: remove unnecessary ubq checks
  2025-04-16 17:01 [PATCH] ublk: remove unnecessary ubq checks Caleb Sander Mateos
@ 2025-04-16 19:47 ` Uday Shankar
  2025-04-17  0:02 ` Ming Lei
  2025-04-23  2:09 ` Jens Axboe
  2 siblings, 0 replies; 5+ messages in thread
From: Uday Shankar @ 2025-04-16 19:47 UTC (permalink / raw)
  To: Caleb Sander Mateos; +Cc: Ming Lei, Jens Axboe, linux-block, linux-kernel

On Wed, Apr 16, 2025 at 11:01:53AM -0600, Caleb Sander Mateos wrote:
> ublk_init_queues() ensures that all nr_hw_queues queues are initialized,
> with each ublk_queue's q_id set to its index. And ublk_init_queues() is
> called before ublk_add_chdev(), which creates the cdev. Is is therefore
> impossible for the !ubq || ub_cmd->q_id != ubq->q_id condition to hit in
> __ublk_ch_uring_cmd(). Remove it to avoids some branches in the I/O path.
> 
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>

Reviewed-by: Uday Shankar <ushankar@purestorage.com>

> ---
>  drivers/block/ublk_drv.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index cdb1543fa4a9..bc86231f5e27 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -1947,13 +1947,10 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
>  
>  	if (ub_cmd->q_id >= ub->dev_info.nr_hw_queues)
>  		goto out;
>  
>  	ubq = ublk_get_queue(ub, ub_cmd->q_id);
> -	if (!ubq || ub_cmd->q_id != ubq->q_id)
> -		goto out;
> -
>  	if (ubq->ubq_daemon && ubq->ubq_daemon != current)
>  		goto out;
>  
>  	if (tag >= ubq->q_depth)
>  		goto out;
> -- 
> 2.45.2
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ublk: remove unnecessary ubq checks
  2025-04-16 17:01 [PATCH] ublk: remove unnecessary ubq checks Caleb Sander Mateos
  2025-04-16 19:47 ` Uday Shankar
@ 2025-04-17  0:02 ` Ming Lei
  2025-04-23  0:40   ` Caleb Sander Mateos
  2025-04-23  2:09 ` Jens Axboe
  2 siblings, 1 reply; 5+ messages in thread
From: Ming Lei @ 2025-04-17  0:02 UTC (permalink / raw)
  To: Caleb Sander Mateos; +Cc: Jens Axboe, linux-block, linux-kernel

On Wed, Apr 16, 2025 at 11:01:53AM -0600, Caleb Sander Mateos wrote:
> ublk_init_queues() ensures that all nr_hw_queues queues are initialized,
> with each ublk_queue's q_id set to its index. And ublk_init_queues() is
> called before ublk_add_chdev(), which creates the cdev. Is is therefore
> impossible for the !ubq || ub_cmd->q_id != ubq->q_id condition to hit in
> __ublk_ch_uring_cmd(). Remove it to avoids some branches in the I/O path.
> 
> Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> ---
>  drivers/block/ublk_drv.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index cdb1543fa4a9..bc86231f5e27 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -1947,13 +1947,10 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
>  
>  	if (ub_cmd->q_id >= ub->dev_info.nr_hw_queues)
>  		goto out;
>  
>  	ubq = ublk_get_queue(ub, ub_cmd->q_id);
> -	if (!ubq || ub_cmd->q_id != ubq->q_id)
> -		goto out;
> -

Looks correct, ubq->q_id is always same with the index passed to
ublk_get_queue().

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


Thanks,
Ming


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ublk: remove unnecessary ubq checks
  2025-04-17  0:02 ` Ming Lei
@ 2025-04-23  0:40   ` Caleb Sander Mateos
  0 siblings, 0 replies; 5+ messages in thread
From: Caleb Sander Mateos @ 2025-04-23  0:40 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, linux-kernel, Ming Lei, Uday Shankar

Hi Jens,
Would you mind queueing up this small patch for 6.16? Uday and Ming
have reviewed it.

Thanks,
Caleb

On Wed, Apr 16, 2025 at 5:02 PM Ming Lei <ming.lei@redhat.com> wrote:
>
> On Wed, Apr 16, 2025 at 11:01:53AM -0600, Caleb Sander Mateos wrote:
> > ublk_init_queues() ensures that all nr_hw_queues queues are initialized,
> > with each ublk_queue's q_id set to its index. And ublk_init_queues() is
> > called before ublk_add_chdev(), which creates the cdev. Is is therefore
> > impossible for the !ubq || ub_cmd->q_id != ubq->q_id condition to hit in
> > __ublk_ch_uring_cmd(). Remove it to avoids some branches in the I/O path.
> >
> > Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
> > ---
> >  drivers/block/ublk_drv.c | 3 ---
> >  1 file changed, 3 deletions(-)
> >
> > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> > index cdb1543fa4a9..bc86231f5e27 100644
> > --- a/drivers/block/ublk_drv.c
> > +++ b/drivers/block/ublk_drv.c
> > @@ -1947,13 +1947,10 @@ static int __ublk_ch_uring_cmd(struct io_uring_cmd *cmd,
> >
> >       if (ub_cmd->q_id >= ub->dev_info.nr_hw_queues)
> >               goto out;
> >
> >       ubq = ublk_get_queue(ub, ub_cmd->q_id);
> > -     if (!ubq || ub_cmd->q_id != ubq->q_id)
> > -             goto out;
> > -
>
> Looks correct, ubq->q_id is always same with the index passed to
> ublk_get_queue().
>
> Reviewed-by: Ming Lei <ming.lei@redhat.com>
>
>
> Thanks,
> Ming
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ublk: remove unnecessary ubq checks
  2025-04-16 17:01 [PATCH] ublk: remove unnecessary ubq checks Caleb Sander Mateos
  2025-04-16 19:47 ` Uday Shankar
  2025-04-17  0:02 ` Ming Lei
@ 2025-04-23  2:09 ` Jens Axboe
  2 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2025-04-23  2:09 UTC (permalink / raw)
  To: Ming Lei, Caleb Sander Mateos; +Cc: linux-block, linux-kernel


On Wed, 16 Apr 2025 11:01:53 -0600, Caleb Sander Mateos wrote:
> ublk_init_queues() ensures that all nr_hw_queues queues are initialized,
> with each ublk_queue's q_id set to its index. And ublk_init_queues() is
> called before ublk_add_chdev(), which creates the cdev. Is is therefore
> impossible for the !ubq || ub_cmd->q_id != ubq->q_id condition to hit in
> __ublk_ch_uring_cmd(). Remove it to avoids some branches in the I/O path.
> 
> 
> [...]

Applied, thanks!

[1/1] ublk: remove unnecessary ubq checks
      commit: 4c7d3c88c77bf227c12ef13e8461a0c940f775e8

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-23  2:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 17:01 [PATCH] ublk: remove unnecessary ubq checks Caleb Sander Mateos
2025-04-16 19:47 ` Uday Shankar
2025-04-17  0:02 ` Ming Lei
2025-04-23  0:40   ` Caleb Sander Mateos
2025-04-23  2:09 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox