scsi: megaraid_sas: Load balance completions across all MSI-X
authorShivasharan S <shivasharan.srikanteshwara@broadcom.com>
Tue, 7 May 2019 17:05:36 +0000 (10:05 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 18 Jun 2019 23:46:19 +0000 (19:46 -0400)
Driver will use "reply descriptor post queues" in round robin fashion when
the combined MSI-X mode is not enabled. With this IO completions are
distributed and load balanced across all the available reply descriptor
post queues equally.

This is enabled only if combined MSI-X mode is not enabled in firmware.
This improves performance and also fixes soft lockups.

When load balancing is enabled, IRQ affinity from driver needs to be
disabled.

Signed-off-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/megaraid/megaraid_sas.h
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fusion.c

index 8d6a9c51145547469cbd919deae287162d98acd8..6be748f302cf4d0460ad9ebe3313fcf2b5bfe524 100644 (file)
@@ -2262,6 +2262,7 @@ struct megasas_instance {
        u32 secure_jbod_support;
        u32 support_morethan256jbod; /* FW support for more than 256 PD/JBOD */
        bool use_seqnum_jbod_fp;   /* Added for PD sequence */
+       bool smp_affinity_enable;
        spinlock_t crashdump_lock;
 
        struct megasas_register_set __iomem *reg_set;
@@ -2279,6 +2280,7 @@ struct megasas_instance {
        u16 ldio_threshold;
        u16 cur_can_queue;
        u32 max_sectors_per_req;
+       bool msix_load_balance;
        struct megasas_aen_event *ev;
 
        struct megasas_cmd **cmd_list;
@@ -2316,6 +2318,7 @@ struct megasas_instance {
        atomic_t sge_holes_type1;
        atomic_t sge_holes_type2;
        atomic_t sge_holes_type3;
+       atomic64_t total_io_count;
 
        struct megasas_instance_template *instancet;
        struct tasklet_struct isr_tasklet;
index ec1259f69683aac381eebd2f3ce43e3d172674eb..6d2390bf7271dba1439bcb8d65b3e2d1311bc53a 100644 (file)
@@ -5349,6 +5349,7 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
                                         &instance->irq_context[j]);
                        /* Retry irq register for IO_APIC*/
                        instance->msix_vectors = 0;
+                       instance->msix_load_balance = false;
                        if (is_probe) {
                                pci_free_irq_vectors(instance->pdev);
                                return megasas_setup_irqs_ioapic(instance);
@@ -5357,6 +5358,7 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe)
                        }
                }
        }
+
        return 0;
 }
 
@@ -5660,6 +5662,12 @@ static int megasas_init_fw(struct megasas_instance *instance)
                                if (rdpq_enable)
                                        instance->is_rdpq = (scratch_pad_1 & MR_RDPQ_MODE_OFFSET) ?
                                                                1 : 0;
+
+                               if (!instance->msix_combined) {
+                                       instance->msix_load_balance = true;
+                                       instance->smp_affinity_enable = false;
+                               }
+
                                fw_msix_count = instance->msix_vectors;
                                /* Save 1-15 reply post index address to local memory
                                 * Index 0 is already saved from reg offset
@@ -5678,17 +5686,20 @@ static int megasas_init_fw(struct megasas_instance *instance)
                                        instance->msix_vectors);
                } else /* MFI adapters */
                        instance->msix_vectors = 1;
+
                /* Don't bother allocating more MSI-X vectors than cpus */
                instance->msix_vectors = min(instance->msix_vectors,
                                             (unsigned int)num_online_cpus());
-               if (smp_affinity_enable)
+               if (instance->smp_affinity_enable)
                        irq_flags |= PCI_IRQ_AFFINITY;
                i = pci_alloc_irq_vectors(instance->pdev, 1,
                                          instance->msix_vectors, irq_flags);
-               if (i > 0)
+               if (i > 0) {
                        instance->msix_vectors = i;
-               else
+               } else {
                        instance->msix_vectors = 0;
+                       instance->msix_load_balance = false;
+               }
        }
        /*
         * MSI-X host index 0 is common for all adapter.
@@ -6795,6 +6806,7 @@ static inline void megasas_init_ctrl_params(struct megasas_instance *instance)
        INIT_LIST_HEAD(&instance->internal_reset_pending_q);
 
        atomic_set(&instance->fw_outstanding, 0);
+       atomic64_set(&instance->total_io_count, 0);
 
        init_waitqueue_head(&instance->int_cmd_wait_q);
        init_waitqueue_head(&instance->abort_cmd_wait_q);
@@ -6817,6 +6829,8 @@ static inline void megasas_init_ctrl_params(struct megasas_instance *instance)
        instance->last_time = 0;
        instance->disableOnlineCtrlReset = 1;
        instance->UnevenSpanSupport = 0;
+       instance->smp_affinity_enable = smp_affinity_enable ? true : false;
+       instance->msix_load_balance = false;
 
        if (instance->adapter_type != MFI_SERIES)
                INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq);
@@ -7180,7 +7194,7 @@ megasas_resume(struct pci_dev *pdev)
        /* Now re-enable MSI-X */
        if (instance->msix_vectors) {
                irq_flags = PCI_IRQ_MSIX;
-               if (smp_affinity_enable)
+               if (instance->smp_affinity_enable)
                        irq_flags |= PCI_IRQ_AFFINITY;
        }
        rval = pci_alloc_irq_vectors(instance->pdev, 1,
index 5fdba1556039c9dbaefc2ab868bf3da2041ab20b..66306ffb34a5f7cb1fa1195e5a8dcd0201026044 100644 (file)
@@ -2768,8 +2768,13 @@ megasas_build_ldio_fusion(struct megasas_instance *instance,
                        fp_possible = (io_info.fpOkForIo > 0) ? true : false;
        }
 
-       cmd->request_desc->SCSIIO.MSIxIndex =
-               instance->reply_map[raw_smp_processor_id()];
+       if (instance->msix_load_balance)
+               cmd->request_desc->SCSIIO.MSIxIndex =
+                       (mega_mod64(atomic64_add_return(1, &instance->total_io_count),
+                                   instance->msix_vectors));
+       else
+               cmd->request_desc->SCSIIO.MSIxIndex =
+                       instance->reply_map[raw_smp_processor_id()];
 
        if (instance->adapter_type >= VENTURA_SERIES) {
                /* FP for Optimal raid level 1.
@@ -3082,8 +3087,13 @@ megasas_build_syspd_fusion(struct megasas_instance *instance,
 
        cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle;
 
-       cmd->request_desc->SCSIIO.MSIxIndex =
-               instance->reply_map[raw_smp_processor_id()];
+       if (instance->msix_load_balance)
+               cmd->request_desc->SCSIIO.MSIxIndex =
+                       (mega_mod64(atomic64_add_return(1, &instance->total_io_count),
+                                   instance->msix_vectors));
+       else
+               cmd->request_desc->SCSIIO.MSIxIndex =
+                       instance->reply_map[raw_smp_processor_id()];
 
        if (!fp_possible) {
                /* system pd firmware path */