Message ID | 20210720232624.1493424-1-nitesh@redhat.com |
---|---|
Headers | show |
Series | genirq: Cleanup the abuse of irq_set_affinity_hint() | expand |
On 7/20/2021 4:26 PM, Nitesh Narayan Lal wrote: > The driver uses irq_set_affinity_hint to set the affinity for the lpfc > interrupts to a mask corresponding to the local NUMA node to avoid > performance overhead on AMD architectures. > > However, irq_set_affinity_hint() setting the affinity is an undocumented > side effect that this function also sets the affinity under the hood. > To remove this side effect irq_set_affinity_hint() has been marked as > deprecated and new interfaces have been introduced. > > Also, as per the commit dcaa21367938 ("scsi: lpfc: Change default IRQ model > on AMD architectures"): > "On AMD architecture, revert the irq allocation to the normal style > (non-managed) and then use irq_set_affinity_hint() to set the cpu affinity > and disable user-space rebalancing." > we don't really need to set the affinity_hint as user-space rebalancing for > the lpfc interrupts is not desired. > > Hence, replace the irq_set_affinity_hint() with irq_set_affinity() which > only applies the affinity for the interrupts. > > Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com> > --- > drivers/scsi/lpfc/lpfc_init.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > Looks good. Thanks Reviewed-by: James Smart <jsmart2021@gmail.com> -- james
Nitesh, > Gentle ping. > Any comments on the following patches: > > scsi: megaraid_sas: Use irq_set_affinity_and_hint > scsi: mpt3sas: Use irq_set_affinity_and_hint Sumit and Sreekanth: Please review. Thanks! -- Martin K. Petersen Oracle Linux Engineering
On Wed, Jul 21, 2021 at 4:57 AM Nitesh Narayan Lal <nitesh@redhat.com> wrote: > > The driver uses irq_set_affinity_hint() specifically for the high IOPS > queue interrupts for two purposes: > > - To set the affinity_hint which is consumed by the userspace for > distributing the interrupts > > - To apply an affinity that it provides > > The driver enforces its own affinity to bind the high IOPS queue interrupts > to the local NUMA node. However, irq_set_affinity_hint() applying the > provided cpumask as an affinity (if not NULL) for the interrupt is an > undocumented side effect. > > To remove this side effect irq_set_affinity_hint() has been marked > as deprecated and new interfaces have been introduced. Hence, replace the > irq_set_affinity_hint() with the new interface irq_set_affinity_and_hint() > where the provided mask needs to be applied as the affinity and > affinity_hint pointer needs to be set and replace with > irq_update_affinity_hint() where only affinity_hint needs to be updated. > Changes looks good and also verified that the high iops queue's IRQs are affinitied to local numa node. Reviewed-by: Sreekanth Reddy <sreekanth.reddy@broadcom.com> > Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com> > --- > drivers/scsi/mpt3sas/mpt3sas_base.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c > index c39955239d1c..c1a11962f227 100644 > --- a/drivers/scsi/mpt3sas/mpt3sas_base.c > +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c > @@ -2991,6 +2991,7 @@ _base_check_enable_msix(struct MPT3SAS_ADAPTER *ioc) > static void > _base_free_irq(struct MPT3SAS_ADAPTER *ioc) > { > + unsigned int irq; > struct adapter_reply_queue *reply_q, *next; > > if (list_empty(&ioc->reply_queue_list)) > @@ -2998,9 +2999,10 @@ _base_free_irq(struct MPT3SAS_ADAPTER *ioc) > > list_for_each_entry_safe(reply_q, next, &ioc->reply_queue_list, list) { > list_del(&reply_q->list); > - if (ioc->smp_affinity_enable) > - irq_set_affinity_hint(pci_irq_vector(ioc->pdev, > - reply_q->msix_index), NULL); > + if (ioc->smp_affinity_enable) { > + irq = pci_irq_vector(ioc->pdev, reply_q->msix_index); > + irq_update_affinity_hint(irq, NULL); > + } > free_irq(pci_irq_vector(ioc->pdev, reply_q->msix_index), > reply_q); > kfree(reply_q); > @@ -3056,16 +3058,13 @@ _base_request_irq(struct MPT3SAS_ADAPTER *ioc, u8 index) > * @ioc: per adapter object > * > * The enduser would need to set the affinity via /proc/irq/#/smp_affinity > - * > - * It would nice if we could call irq_set_affinity, however it is not > - * an exported symbol > */ > static void > _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, irq; > struct adapter_reply_queue *reply_q; > - int local_numa_node; > + const struct cpumask *mask; > > if (!_base_is_controller_msix_enabled(ioc)) > return; > @@ -3088,11 +3087,11 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc) > * corresponding to high iops queues. > */ > if (ioc->high_iops_queues) { > - local_numa_node = dev_to_node(&ioc->pdev->dev); > + mask = cpumask_of_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)); > + irq = pci_irq_vector(ioc->pdev, index); > + irq_set_affinity_and_hint(irq, mask); > } > } > > -- > 2.27.0 >
On Wed, Jul 21, 2021 at 7:26 AM Nitesh Narayan Lal <nitesh@redhat.com> wrote: > > From: Thomas Gleixner <tglx@linutronix.de> > > The discussion about removing the side effect of irq_set_affinity_hint() of > actually applying the cpumask (if not NULL) as affinity to the interrupt, > unearthed a few unpleasantries: > > 1) The modular perf drivers rely on the current behaviour for the very > wrong reasons. > > 2) While none of the other drivers prevents user space from changing > the affinity, a cursorily inspection shows that there are at least > expectations in some drivers. > > #1 needs to be cleaned up anyway, so that's not a problem > > #2 might result in subtle regressions especially when irqbalanced (which > nowadays ignores the affinity hint) is disabled. > > Provide new interfaces: > > irq_update_affinity_hint() - Only sets the affinity hint pointer > irq_set_affinity_and_hint() - Set the pointer and apply the affinity to > the interrupt > > Make irq_set_affinity_hint() a wrapper around irq_apply_affinity_hint() and > document it to be phased out. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com> > Link: https://lore.kernel.org/r/20210501021832.743094-1-jesse.brandeburg@intel.com Reviewed-by: Ming Lei <ming.lei@redhat.com>
On Mon, Aug 16, 2021 at 11:50 AM Nitesh Lal <nilal@redhat.com> wrote: > > On Mon, Aug 2, 2021 at 11:26 AM Nitesh Lal <nilal@redhat.com> wrote: > > > > On Tue, Jul 20, 2021 at 7:26 PM Nitesh Narayan Lal <nitesh@redhat.com> wrote: > > > > > > The drivers currently rely on irq_set_affinity_hint() to either set the > > > affinity_hint that is consumed by the userspace and/or to enforce a custom > > > affinity. > > > > [...] > > Any comments on the following patches: > > enic: Use irq_update_affinity_hint > be2net: Use irq_update_affinity_hint > mailbox: Use irq_update_affinity_hint > hinic: Use irq_set_affinity_and_hint > > or any other patches? > Any help in testing will also be very useful. > Gentle ping. Any comments on the following patches: be2net: Use irq_update_affinity_hint hinic: Use irq_set_affinity_and_hint or any other patches? -- Thanks Nitesh