Message ID | 20230901094127.2010873-10-haowenchao2@huawei.com |
---|---|
State | New |
Headers | show |
Series | scsi: scsi_error: Introduce new error handle mechanism | expand |
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@huawei.com> > --- > 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.
On 2023/9/6 7:55, Mike Christie wrote: > 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@huawei.com> >> --- >> 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. > Would update in next version
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); sbitmap_put(&sdev->budget_map, cmd->budget_token); cmd->budget_token = -1; @@ -1311,10 +1310,10 @@ static inline int scsi_target_queue_ready(struct Scsi_Host *shost, spin_unlock_irq(shost->host_lock); } + busy = atomic_inc_return(&starget->target_busy) - 1; if (starget->can_queue <= 0) return 1; - busy = atomic_inc_return(&starget->target_busy) - 1; if (atomic_read(&starget->target_blocked) > 0) { if (busy) goto starved; @@ -1339,8 +1338,7 @@ static inline int scsi_target_queue_ready(struct Scsi_Host *shost, list_move_tail(&sdev->starved_entry, &shost->starved_list); spin_unlock_irq(shost->host_lock); out_dec: - if (starget->can_queue > 0) - atomic_dec(&starget->target_busy); + atomic_dec(&starget->target_busy); return 0; } @@ -1784,8 +1782,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, out_dec_host_busy: scsi_dec_host_busy(shost, cmd); out_dec_target_busy: - if (scsi_target(sdev)->can_queue > 0) - atomic_dec(&scsi_target(sdev)->target_busy); + atomic_dec(&scsi_target(sdev)->target_busy); out_put_budget: scsi_mq_put_budget(q, cmd->budget_token); cmd->budget_token = -1;
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@huawei.com> --- drivers/scsi/scsi_lib.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)