Re: [RFC PATCH v2 09/19] scsi: core: increase/decrease target_busy without check can_queue

From: Mike Christie
Date: Tue Sep 05 2023 - 19:55:57 EST


On 9/1/23 4:41 AM, Wenchao Hao wrote:
> This is preparation for a genernal target based error handle strategy
> to check if to wake up actual error handler.
>
> Signed-off-by: Wenchao Hao <haowenchao2@xxxxxxxxxx>
> ---
> drivers/scsi/scsi_lib.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index db0a42fe49c0..4a7fb48aa60f 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -293,8 +293,7 @@ void scsi_device_unbusy(struct scsi_device *sdev, struct scsi_cmnd *cmd)
>
> scsi_dec_host_busy(shost, cmd);
>
> - if (starget->can_queue > 0)
> - atomic_dec(&starget->target_busy);
> + atomic_dec(&starget->target_busy);
>

Ming had found that removing the atomics improves perf.
Since most drivers didn't care about the target level counters
it was moved to the can_queue check so only drivers using the
feature suffer the perf hit.

Your patch should do the same.