scsi: add use_cmd_list flag
authorKashyap.Desai@avagotech.com <Kashyap.Desai@avagotech.com>
Wed, 20 Aug 2014 13:54:33 +0000 (19:24 +0530)
committerChristoph Hellwig <hch@lst.de>
Mon, 15 Sep 2014 23:01:58 +0000 (16:01 -0700)
Add a use_cmd_list flag in struct Scsi_Host to request keeping track of
all outstanding commands per device.

Default behaviour is not to keep track of cmd_list per sdev, as this may
introduce lock contention. (overhead is more on multi-node NUMA.), and
only enable it on the two drivers that need it.

Signed-off-by: Kashyap Desai <kashyap.desai@avagotech.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/aacraid/linit.c
drivers/scsi/dpt_i2o.c
drivers/scsi/scsi_lib.c
include/scsi/scsi_host.h

index 63f576c9300a7d317a0b7b5f0b8baa3090dd070d..a759cb2d4b15e65868b578a8c3110a7bd6f647b9 100644 (file)
@@ -1152,6 +1152,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        shost->irq = pdev->irq;
        shost->unique_id = unique_id;
        shost->max_cmd_len = 16;
+       shost->use_cmd_list = 1;
 
        aac = (struct aac_dev *)shost->hostdata;
        aac->base_start = pci_resource_start(pdev, 0);
index 67283ef418ac86fcc6d169033c7b68ae99379d0b..072f0ec2851e252d8ccaf2a1dd1d0b26742079fc 100644 (file)
@@ -2363,6 +2363,7 @@ static s32 adpt_scsi_host_alloc(adpt_hba* pHba, struct scsi_host_template *sht)
        host->unique_id = (u32)sys_tbl_pa + pHba->unit;
        host->sg_tablesize = pHba->sg_tablesize;
        host->can_queue = pHba->post_fifo_size;
+       host->use_cmd_list = 1;
 
        return 0;
 }
index d837dc180522142fa1dcaf5b4e09c141effbfc4a..b9a8ddd77eef80b31d5770f54ccb116158df82a9 100644 (file)
@@ -645,16 +645,18 @@ static void scsi_mq_free_sgtables(struct scsi_cmnd *cmd)
 static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
 {
        struct scsi_device *sdev = cmd->device;
+       struct Scsi_Host *shost = sdev->host;
        unsigned long flags;
 
-       BUG_ON(list_empty(&cmd->list));
-
        scsi_mq_free_sgtables(cmd);
        scsi_uninit_cmd(cmd);
 
-       spin_lock_irqsave(&sdev->list_lock, flags);
-       list_del_init(&cmd->list);
-       spin_unlock_irqrestore(&sdev->list_lock, flags);
+       if (shost->use_cmd_list) {
+               BUG_ON(list_empty(&cmd->list));
+               spin_lock_irqsave(&sdev->list_lock, flags);
+               list_del_init(&cmd->list);
+               spin_unlock_irqrestore(&sdev->list_lock, flags);
+       }
 }
 
 /*
@@ -1815,13 +1817,11 @@ static int scsi_mq_prep_fn(struct request *req)
        INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler);
        cmd->jiffies_at_alloc = jiffies;
 
-       /*
-        * XXX: cmd_list lookups are only used by two drivers, try to get
-        * rid of this list in common code.
-        */
-       spin_lock_irq(&sdev->list_lock);
-       list_add_tail(&cmd->list, &sdev->cmd_list);
-       spin_unlock_irq(&sdev->list_lock);
+       if (shost->use_cmd_list) {
+               spin_lock_irq(&sdev->list_lock);
+               list_add_tail(&cmd->list, &sdev->cmd_list);
+               spin_unlock_irq(&sdev->list_lock);
+       }
 
        sg = (void *)cmd + sizeof(struct scsi_cmnd) + shost->hostt->cmd_size;
        cmd->sdb.table.sgl = sg;
index ba2034779961ae85fff76a46ffb8be75d7c38352..cafb260ef2d344deaf8da062afb853fe19b9a1b3 100644 (file)
@@ -680,6 +680,7 @@ struct Scsi_Host {
        unsigned no_write_same:1;
 
        unsigned use_blk_mq:1;
+       unsigned use_cmd_list:1;
 
        /*
         * Optional work queue to be utilized by the transport