Skip to content

Commit

Permalink
Revert "scsi: core: avoid host-wide host_busy counter for scsi_mq"
Browse files Browse the repository at this point in the history
This reverts commit 3287286.

There is fundamental issue in commit 3287286 (scsi: core: avoid
host-wide host_busy counter for scsi_mq) because SCSI's host busy counter
may not be same with counter of blk-mq's inflight tags, especially in case
of none io scheduler.

We may switch to other approach for addressing this scsi_mq's performance
issue, such as percpu counter or kind of ways, so revert this commit first
for fixing this kind of issue in EH path, as reported by Jens.

Cc: Omar Sandoval <osandov@fb.com>,
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
Cc: James Bottomley <james.bottomley@hansenpartnership.com>,
Cc: Christoph Hellwig <hch@lst.de>,
Cc: Don Brace <don.brace@microsemi.com>
Cc: Kashyap Desai <kashyap.desai@broadcom.com>
Cc: Mike Snitzer <snitzer@redhat.com>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Laurence Oberman <loberman@redhat.com>
Cc: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Jens Axboe <axboe@kernel.dk>
Reported-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Ming Lei authored and martinkpetersen committed Aug 27, 2018
1 parent 23aa8e6 commit d772a65
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 40 deletions.
24 changes: 1 addition & 23 deletions drivers/scsi/hosts.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,35 +563,13 @@ struct Scsi_Host *scsi_host_get(struct Scsi_Host *shost)
}
EXPORT_SYMBOL(scsi_host_get);

struct scsi_host_mq_in_flight {
int cnt;
};

static void scsi_host_check_in_flight(struct request *rq, void *data,
bool reserved)
{
struct scsi_host_mq_in_flight *in_flight = data;

if (blk_mq_request_started(rq))
in_flight->cnt++;
}

/**
* scsi_host_busy - Return the host busy counter
* @shost: Pointer to Scsi_Host to inc.
**/
int scsi_host_busy(struct Scsi_Host *shost)
{
struct scsi_host_mq_in_flight in_flight = {
.cnt = 0,
};

if (!shost->use_blk_mq)
return atomic_read(&shost->host_busy);

blk_mq_tagset_busy_iter(&shost->tag_set, scsi_host_check_in_flight,
&in_flight);
return in_flight.cnt;
return atomic_read(&shost->host_busy);
}
EXPORT_SYMBOL(scsi_host_busy);

Expand Down
23 changes: 6 additions & 17 deletions drivers/scsi/scsi_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ static void scsi_dec_host_busy(struct Scsi_Host *shost)
unsigned long flags;

rcu_read_lock();
if (!shost->use_blk_mq)
atomic_dec(&shost->host_busy);
atomic_dec(&shost->host_busy);
if (unlikely(scsi_host_in_recovery(shost))) {
spin_lock_irqsave(shost->host_lock, flags);
if (shost->host_failed || shost->host_eh_scheduled)
Expand Down Expand Up @@ -445,12 +444,7 @@ static inline bool scsi_target_is_busy(struct scsi_target *starget)

static inline bool scsi_host_is_busy(struct Scsi_Host *shost)
{
/*
* blk-mq can handle host queue busy efficiently via host-wide driver
* tag allocation
*/

if (!shost->use_blk_mq && shost->can_queue > 0 &&
if (shost->can_queue > 0 &&
atomic_read(&shost->host_busy) >= shost->can_queue)
return true;
if (atomic_read(&shost->host_blocked) > 0)
Expand Down Expand Up @@ -1606,12 +1600,9 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
if (scsi_host_in_recovery(shost))
return 0;

if (!shost->use_blk_mq)
busy = atomic_inc_return(&shost->host_busy) - 1;
else
busy = 0;
busy = atomic_inc_return(&shost->host_busy) - 1;
if (atomic_read(&shost->host_blocked) > 0) {
if (busy || scsi_host_busy(shost))
if (busy)
goto starved;

/*
Expand All @@ -1625,7 +1616,7 @@ static inline int scsi_host_queue_ready(struct request_queue *q,
"unblocking host at zero depth\n"));
}

if (!shost->use_blk_mq && shost->can_queue > 0 && busy >= shost->can_queue)
if (shost->can_queue > 0 && busy >= shost->can_queue)
goto starved;
if (shost->host_self_blocked)
goto starved;
Expand Down Expand Up @@ -1711,9 +1702,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
* with the locks as normal issue path does.
*/
atomic_inc(&sdev->device_busy);

if (!shost->use_blk_mq)
atomic_inc(&shost->host_busy);
atomic_inc(&shost->host_busy);
if (starget->can_queue > 0)
atomic_inc(&starget->target_busy);

Expand Down

0 comments on commit d772a65

Please sign in to comment.