scsi: mpt3sas: Affinity high iops queues IRQs to local node

High iops queues are mapped to non-managed irqs. Set affinity of
non-managed irqs to local numa node.  Low latency queues are mapped to
managed irqs.

Driver reserves some reply queues for max iops (through
pci_alloc_irq_vectors_affinity and .pre_vectors interface). The rest of
queues are for low latency.

Based on io workload in io submission path, driver will decide which group
of reply queues (either high iops queues or low latency queues) to be
used. High iops queues will be mapped to local numa node of controller and
low latency queues will be mapped to cpus across numa nodes. In general,
high iops and low latency queues should fit into 128 reply queues
which is the max number of reply queues supported by Aero/Sea.

Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Suganath Prabu S 2019-05-31 08:14:40 -04:00 committed by Martin K. Petersen
parent 998c3001d3
commit 728bbc6cbf

View File

@ -2793,6 +2793,9 @@ _base_free_irq(struct MPT3SAS_ADAPTER *ioc)
list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) { list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) {
list_del(&reply_q->list); list_del(&reply_q->list);
if (smp_affinity_enable)
irq_set_affinity_hint(pci_irq_vector(ioc->pdev,
reply_q->msix_index), NULL);
free_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index), free_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index),
reply_q); reply_q);
kfree(reply_q); kfree(reply_q);
@ -2857,6 +2860,7 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
{ {
unsigned int cpu, nr_cpus, nr_msix, index = 0; unsigned int cpu, nr_cpus, nr_msix, index = 0;
struct adapter_reply_queue *reply_q; struct adapter_reply_queue *reply_q;
int local_numa_node;
if (!_base_is_controller_msix_enabled(ioc)) if (!_base_is_controller_msix_enabled(ioc))
return; return;
@ -2875,13 +2879,32 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
return; return;
if (smp_affinity_enable) { if (smp_affinity_enable) {
/*
* set irq affinity to local numa node for those irqs
* corresponding to high iops queues.
*/
if (ioc->high_iops_queues) {
local_numa_node = dev_to_node(&ioc->pdev->dev);
for (index = 0; index < ioc->high_iops_queues;
index++) {
irq_set_affinity_hint(pci_irq_vector(ioc->pdev,
index), cpumask_of_node(local_numa_node));
}
}
list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
const cpumask_t *mask = pci_irq_get_affinity(ioc->pdev, const cpumask_t *mask;
reply_q->msix_index);
if (reply_q->msix_index < ioc->high_iops_queues)
continue;
mask = pci_irq_get_affinity(ioc->pdev,
reply_q->msix_index);
if (!mask) { if (!mask) {
ioc_warn(ioc, "no affinity for msi %x\n", ioc_warn(ioc, "no affinity for msi %x\n",
reply_q->msix_index); reply_q->msix_index);
continue; goto fall_back;
} }
for_each_cpu_and(cpu, mask, cpu_online_mask) { for_each_cpu_and(cpu, mask, cpu_online_mask) {
@ -2892,12 +2915,18 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
} }
return; return;
} }
fall_back:
cpu = cpumask_first(cpu_online_mask); cpu = cpumask_first(cpu_online_mask);
nr_msix -= ioc->high_iops_queues;
index = 0;
list_for_each_entry(reply_q, &ioc->reply_queue_list, list) { list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
unsigned int i, group = nr_cpus / nr_msix; unsigned int i, group = nr_cpus / nr_msix;
if (reply_q->msix_index < ioc->high_iops_queues)
continue;
if (cpu >= nr_cpus) if (cpu >= nr_cpus)
break; break;
@ -2950,10 +2979,37 @@ _base_disable_msix(struct MPT3SAS_ADAPTER *ioc)
{ {
if (!ioc->msix_enable) if (!ioc->msix_enable)
return; return;
pci_disable_msix(ioc->pdev); pci_free_irq_vectors(ioc->pdev);
ioc->msix_enable = 0; ioc->msix_enable = 0;
} }
/**
* _base_alloc_irq_vectors - allocate msix vectors
* @ioc: per adapter object
*
*/
static int
_base_alloc_irq_vectors(struct MPT3SAS_ADAPTER *ioc)
{
int i, irq_flags = PCI_IRQ_MSIX;
struct irq_affinity desc = { .pre_vectors = ioc->high_iops_queues };
struct irq_affinity *descp = &desc;
if (smp_affinity_enable)
irq_flags |= PCI_IRQ_AFFINITY;
else
descp = NULL;
ioc_info(ioc, " %d %d\n", ioc->high_iops_queues,
ioc->msix_vector_count);
i = pci_alloc_irq_vectors_affinity(ioc->pdev,
ioc->high_iops_queues,
ioc->msix_vector_count, irq_flags, descp);
return i;
}
/** /**
* _base_enable_msix - enables msix, failback to io_apic * _base_enable_msix - enables msix, failback to io_apic
* @ioc: per adapter object * @ioc: per adapter object
@ -2965,7 +3021,6 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc)
int r; int r;
int i, local_max_msix_vectors; int i, local_max_msix_vectors;
u8 try_msix = 0; u8 try_msix = 0;
unsigned int irq_flags = PCI_IRQ_MSIX;
if (msix_disable == -1 || msix_disable == 0) if (msix_disable == -1 || msix_disable == 0)
try_msix = 1; try_msix = 1;
@ -2999,11 +3054,7 @@ _base_enable_msix(struct MPT3SAS_ADAPTER *ioc)
if (ioc->msix_vector_count < ioc->cpu_count) if (ioc->msix_vector_count < ioc->cpu_count)
smp_affinity_enable = 0; smp_affinity_enable = 0;
if (smp_affinity_enable) r = _base_alloc_irq_vectors(ioc);
irq_flags |= PCI_IRQ_AFFINITY;
r = pci_alloc_irq_vectors(ioc->pdev, 1, ioc->reply_queue_count,
irq_flags);
if (r < 0) { if (r < 0) {
dfailprintk(ioc, dfailprintk(ioc,
ioc_info(ioc, "pci_alloc_irq_vectors failed (r=%d) !!!\n", ioc_info(ioc, "pci_alloc_irq_vectors failed (r=%d) !!!\n",