genirq: Cleanup the abuse of irq_set_affinity_hint()
Subsystems (18)
v5 cover genirq: Cleanup the abuse of irq_set_affinity_hint()
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.
irq_set_affinity_hint() as the name suggests is originally introduced to only set the affinity_hint to help the userspace in guiding the interrupts and not the affinity itself. However, since the commit
e2e64a932556 "genirq: Set initial affinity in irq_set_affinity_hint()"
irq_set_affinity_hint() also started applying the provided cpumask (if not NULL) as the affinity for the interrupts. The issue that this commit was trying to solve is to allow the drivers to enforce their affinity mask to distribute the interrupts across the CPUs such that they don't always end up on CPU0. This issue has been resolved within the irq subsystem since the commit
a0c9259dc4e1 "irq/matrix: Spread interrupts on allocation"
Hence, there is no need for the drivers to overwrite the affinity to spread as it is dynamically performed at the time of allocation.
Also, irq_set_affinity_hint() setting affinity unconditionally introduces issues for the drivers that only want to set their affinity_hint and not the affinity itself as for these driver interrupts the default_smp_affinity_mask is completely ignored (for detailed investigation please refer to [1]).
Unfortunately reverting the commit e2e64a932556 is not an option at this point for two reasons [2]:
- Several drivers for a valid reason (performance) rely on this API to enforce their affinity mask
- Until very recently this was the only exported interface that was available
To clear this out Thomas has come up with the following interfaces:
- irq_set_affinity(): only sets affinity of an IRQ [3]
- irq_update_affinity_hint(): Only sets the hint [4]
- irq_set_affinity_and_hint(): Sets both affinity and the hint mask [4]
The first API is already merged in the linus's tree and the patch that introduces the other two interfaces is included with this patch-set.
To move to the stage where we can safely get rid of the irq_set_affinity_hint(), which has been marked deprecated, we have to move all its consumers to these new interfaces. In this patch-set, I have done that for a few drivers and will hopefully try to move the remaining of them in the coming days.
Testing
-------
In terms of testing, I have performed some basic testing on x86 to verify things such as the interrupts are evenly spread on all CPUs, hint mask is correctly set etc. for the drivers - i40e, iavf, mlx5, mlx4, ixgbe, and enic on top of:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
So more testing is probably required for these and the drivers that I didn't test and any help will be much appreciated.
Notes
-----
- For the mpt3sas driver I decided to go with the usage of irq_set_affinity_and_hint over irq_set_affinity based on my analysis of it and the megaraid driver. However, if we are sure that it is not required then I can replace it with just irq_set_affinity as one of its comment suggests.
Change from v4 [5]
------------------
- Fixed kernel-doc warnings (Jakub Kicinski)
- Renamed the cover to "Cleanup the abuse of irq_set_affinity_hint()", what Thomas originally used as this series is an extension of the work that he started and proposed [6].
Change from v3 [7]
------------------
- Replaced irq_set_affinity_and_hint with irq_update_affinity_hint in irdma (Leon Romanovsky)
- rebased the patches on top of 5.14-rc2
Change from v2 [8]
------------------
- Rebased on top of 5.14-rc1 (Leon Romanovsky)
+ After discussion with Leon [9], made changes in the mlx5 patch to use irq_set_affinity_and_hint over irq_update_affinity_hint
+ i40iw is replaced with irdma driver, hence made the respective changes in irdma (also replcaed irq_update_affinity_hint with irq_set_affinity_and_hint).
Change from v1 [10]
------------------
- Fixed compilation error by adding the new interface definitions for cases where CONFIG_SMP is not defined
- Fixed function usage in megaraid_sas and removed unnecessary variable (Robin Murphy)
- Removed unwanted #if/endif from mlx4 (Leon Romanovsky)
- Other indentation related fixes
[1] https://lore.kernel.org/lkml/1a044a14-0884-eedb-5d30-28b4bec24b23 at redhat.com/
[2] https://lore.kernel.org/linux-pci/d1d5e797-49ee-4968-88c6-c07119343492 at arm.com/
[3] https://lore.kernel.org/linux-arm-kernel/20210518091725.046774792 at linutronix.de/
[4] https://lore.kernel.org/patchwork/patch/1434326/
[5] https://lore.kernel.org/lkml/20210719180746.1008665-1-nitesh at redhat.com/
[6] https://lore.kernel.org/linux-arm-kernel/20210518091725.046774792 at linutronix.de/
[7] https://lore.kernel.org/linux-scsi/20210713211502.464259-1-nitesh at redhat.com/
[8] https://lore.kernel.org/lkml/20210629152746.2953364-1-nitesh at redhat.com/
[9] https://lore.kernel.org/lkml/YO0eKv2GJcADQTHH at unreal/
[10] https://lore.kernel.org/linux-scsi/20210617182242.8637-1-nitesh at redhat.com/
Nitesh Narayan Lal (13):
iavf: Use irq_update_affinity_hint
i40e: Use irq_update_affinity_hint
scsi: megaraid_sas: Use irq_set_affinity_and_hint
scsi: mpt3sas: Use irq_set_affinity_and_hint RDMA/irdma: Use irq_update_affinity_hint
enic: Use irq_update_affinity_hint
be2net: Use irq_update_affinity_hint
ixgbe: Use irq_update_affinity_hint
mailbox: Use irq_update_affinity_hint
scsi: lpfc: Use irq_set_affinity
hinic: Use irq_set_affinity_and_hint net/mlx5: Use irq_set_affinity_and_hint net/mlx4: Use irq_update_affinity_hint
Thomas Gleixner (1):
genirq: Provide new interfaces for affinity hints
drivers/infiniband/hw/irdma/hw.c | 4 +- drivers/mailbox/bcm-flexrm-mailbox.c | 4 +- drivers/net/ethernet/cisco/enic/enic_main.c | 8 +-- drivers/net/ethernet/emulex/benet/be_main.c | 4 +- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 8 +-- drivers/net/ethernet/intel/iavf/iavf_main.c | 8 +-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 ++-- drivers/net/ethernet/mellanox/mlx4/eq.c | 8 ++- .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 8 +-- drivers/scsi/lpfc/lpfc_init.c | 4 +- drivers/scsi/megaraid/megaraid_sas_base.c | 27 +++++----- drivers/scsi/mpt3sas/mpt3sas_base.c | 21 ++++---- include/linux/interrupt.h | 53 ++++++++++++++++++- kernel/irq/manage.c | 8 +-- 15 files changed, 114 insertions(+), 65 deletions(-)
PATCH v5 1/14 genirq: Provide new interfaces for affinity hints
From: Thomas Gleixner <[email protected]>
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.
--- include/linux/interrupt.h | 53 ++++++++++++++++++++++++++++++++++++++- kernel/irq/manage.c | 8 +++--- 2 files changed, 56 insertions(+), 5 deletions(-)
include/linux/interrupt.h +52 -1
@@ -328,7 +328,46 @@ extern int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask);extern int irq_can_set_affinity (unsigned int irq);extern int irq_select_affinity (unsigned int irq); -extern int irq_set_affinity_hint (unsigned int irq,const struct cpumask *m); +extern int __irq_apply_affinity_hint (unsigned int irq,const struct cpumask *m, +bool setaffinity); + +/** +* irq_update_affinity_hint - Update the affinity hint +* @irq: Interrupt to update +* @m: cpumask pointer (NULL to clear the hint) +* +* Updates the affinity hint, but does not change the affinity of the interrupt. +*/ +static inline int +irq_update_affinity_hint (unsigned int irq,const struct cpumask *m) +{ +return __irq_apply_affinity_hint (irq, m, false); +} + +/** +* irq_set_affinity_and_hint - Update the affinity hint and apply the provided +* cpumask to the interrupt +* @irq: Interrupt to update +* @m: cpumask pointer (NULL to clear the hint) +* +* Updates the affinity hint and if @m is not NULL it applies it as the +* affinity of that interrupt. +*/ +static inline int +irq_set_affinity_and_hint (unsigned int irq,const struct cpumask *m) +{ +return __irq_apply_affinity_hint (irq, m, true); +} + +/* +* Deprecated. Use irq_update_affinity_hint() or irq_set_affinity_and_hint() +* instead. +*/ +static inline int irq_set_affinity_hint (unsigned int irq,const struct cpumask *m) +{ +return irq_set_affinity_and_hint (irq, m); +} +extern int irq_update_affinity_desc (unsigned int irq,struct irq_affinity_desc *affinity);
@@ -360,6 +399,18 @@ static inline int irq_can_set_affinity(unsigned int irq)static inline int irq_select_affinity (unsigned int irq) {return 0 ; } +static inline int irq_update_affinity_hint (unsigned int irq, +const struct cpumask *m) +{ +return -EINVAL ; +} + +static inline int irq_set_affinity_and_hint (unsigned int irq, +const struct cpumask *m) +{ +return -EINVAL ; +} +static inline int irq_set_affinity_hint (unsigned int irq,const struct cpumask *m) {
kernel/irq/manage.c +4 -4
@@ -487,7 +487,8 @@ int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) }EXPORT_SYMBOL_GPL (irq_force_affinity); -int irq_set_affinity_hint (unsigned int irq,const struct cpumask *m) +int __irq_apply_affinity_hint (unsigned int irq,const struct cpumask *m, +bool setaffinity) {unsigned long flags;struct irq_desc *desc =irq_get_desc_lock (irq, &flags,IRQ_GET_DESC_CHECK_GLOBAL );
@@ -496,12 +497,11 @@ int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)return -EINVAL ; desc->affinity_hint = m;irq_put_desc_unlock (desc, flags); -/* set the initial affinity to prevent every interrupt being on CPU0 */ -if (m) +if (m && setaffinity)__irq_set_affinity (irq, m, false);return 0 ; } -EXPORT_SYMBOL_GPL (irq_set_affinity_hint); +EXPORT_SYMBOL_GPL (__irq_apply_affinity_hint);static void irq_affinity_notify (struct work_struct *work) {
Signature · 1 line
2.27.0
Re: [PATCH v5 01/14] genirq: Provide new interfaces for affinity hints
Quoted 25 lines · Nitesh Narayan Lal
From: Thomas Gleixner <[email protected]>
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 pointerirq_set_affinity_and_hint()- Set the pointer and apply the affinity to
the interrupt
Quoted 6 lines
Make
irq_set_affinity_hint()a wrapper aroundirq_apply_affinity_hint()and document it to be phased out.Signed-off-by Thomas Gleixner <[email protected]>Signed-off-by Nitesh Narayan Lal <[email protected]>Link https://lore.kernel.org/r/20210501021832.743094-1-jesse.brandeburg at intel.com
PATCH v5 2/14 iavf: Use irq_update_affinity_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() 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 for the iavf interrupts
The latter is done to ensure that all the interrupts are evenly spread across all available CPUs. However, since commit a0c9259dc4e1 ("irq/matrix:
Spread interrupts on allocation") the spreading of interrupts is dynamically performed at the time of allocation. Hence, there is no need for the drivers to enforce their own affinity for the spreading of interrupts.
Also, irq_set_affinity_hint() applying the provided cpumask as an affinity 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_update_affinity_hint() that only sets the pointer for the affinity_hint.
--- drivers/net/ethernet/intel/iavf/iavf_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +4 -4
@@ -449,10 +449,10 @@ iavf_request_traffic_irqs(struct iavf_adapter *adapter, char *basename)irq_set_affinity_notifier (irq_num, &q_vector->affinity_notify);/* Spread the IRQ affinity hints across online CPUs. Note that * get_cpu_mask returns a mask with a permanent lifetime so -* it's safe to use as a hint for irq_set_affinity_hint. +* it's safe to use as a hint for irq_update_affinity_hint. */ cpu =cpumask_local_spread (q_vector->v_idx,-1 ); -irq_set_affinity_hint (irq_num,get_cpu_mask (cpu)); +irq_update_affinity_hint (irq_num,get_cpu_mask (cpu)); }return 0 ;
@@ -462,7 +462,7 @@ iavf_request_traffic_irqs(struct iavf_adapter *adapter, char *basename) vector--; irq_num = adapter->msix_entries[vector +NONQ_VECS ].vector;irq_set_affinity_notifier (irq_num,NULL ); -irq_set_affinity_hint (irq_num,NULL ); +irq_update_affinity_hint (irq_num,NULL );free_irq (irq_num, &adapter->q_vectors[vector]); }return err;
@@ -514,7 +514,7 @@ static void iavf_free_traffic_irqs(struct iavf_adapter *adapter)for (vector =0 ; vector < q_vectors; vector++) { irq_num = adapter->msix_entries[vector +NONQ_VECS ].vector;irq_set_affinity_notifier (irq_num,NULL ); -irq_set_affinity_hint (irq_num,NULL ); +irq_update_affinity_hint (irq_num,NULL );free_irq (irq_num, &adapter->q_vectors[vector]); } }
Signature · 1 line
2.27.0
PATCH v5 3/14 i40e: Use irq_update_affinity_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() 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 for the i40e interrupts
The latter is done to ensure that all the interrupts are evenly spread across all available CPUs. However, since commit a0c9259dc4e1 ("irq/matrix:
Spread interrupts on allocation") the spreading of interrupts is dynamically performed at the time of allocation. Hence, there is no need for the drivers to enforce their own affinity for the spreading of interrupts.
Also, irq_set_affinity_hint() applying the provided cpumask as an affinity 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_update_affinity_hint() that only sets the pointer for the affinity_hint.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +4 -4
@@ -3873,10 +3873,10 @@ static int i40e_vsi_request_irq_msix(struct i40e_vsi *vsi, char *basename)* * get_cpu_mask returns a static constant mask with * a permanent lifetime so it's ok to pass to -* irq_set_affinity_hint without making a copy. +* irq_update_affinity_hint without making a copy. */ cpu =cpumask_local_spread (q_vector->v_idx,-1 ); -irq_set_affinity_hint (irq_num,get_cpu_mask (cpu)); +irq_update_affinity_hint (irq_num,get_cpu_mask (cpu)); } vsi->irqs_ready = true;
@@ -3887,7 +3887,7 @@ static int i40e_vsi_request_irq_msix(struct i40e_vsi *vsi, char *basename) vector--; irq_num = pf->msix_entries[base + vector].vector;irq_set_affinity_notifier (irq_num,NULL ); -irq_set_affinity_hint (irq_num,NULL ); +irq_update_affinity_hint (irq_num,NULL );free_irq (irq_num, &vsi->q_vectors[vector]); }return err;
@@ -4695,7 +4695,7 @@ static void i40e_vsi_free_irq(struct i40e_vsi *vsi)/* clear the affinity notifier in the IRQ descriptor */ irq_set_affinity_notifier (irq_num,NULL );/* remove our suggested affinity mask for this IRQ */ -irq_set_affinity_hint (irq_num,NULL ); +irq_update_affinity_hint (irq_num,NULL );synchronize_irq (irq_num);free_irq (irq_num, vsi->q_vectors[i]);
Signature · 1 line
2.27.0
PATCH v5 4/14 scsi: megaraid_sas: Use irq_set_affinity_and_hint
In reply to Nitesh Narayan LalThe 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 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.
Change the megasas_set_high_iops_queue_affinity_hint function name to megasas_set_high_iops_queue_affinity_and_hint to clearly indicate that the function is setting both affinity and affinity_hint.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 27 +++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +15 -12
@@ -5718,7 +5718,7 @@ megasas_setup_irqs_msix(struct megasas_instance *instance, u8 is_probe) "Failed to register IRQ for vector %d.\n", i);for (j =0 ; j < i; j++) {if (j < instance->low_latency_index_start) -irq_set_affinity_hint ( +irq_update_affinity_hint (pci_irq_vector (pdev, j),NULL );free_irq (pci_irq_vector (pdev, j), &instance->irq_context[j]);
@@ -5761,7 +5761,7 @@ megasas_destroy_irqs(struct megasas_instance *instance) {if (instance->msix_vectors)for (i =0 ; i < instance->msix_vectors; i++) {if (i < instance->low_latency_index_start) -irq_set_affinity_hint ( +irq_update_affinity_hint (pci_irq_vector (instance->pdev, i),NULL );free_irq (pci_irq_vector (instance->pdev, i), &instance->irq_context[i]);
@@ -5892,22 +5892,25 @@ int megasas_get_device_list(struct megasas_instance *instance) }/** -* megasas_set_high_iops_queue_affinity_hint - Set affinity hint for high IOPS queues -* @instance: Adapter soft state -* return: void +* megasas_set_high_iops_queue_affinity_and_hint - Set affinity and hint +* for high IOPS queues +* @instance: Adapter soft state +* return: void */ static inline void -megasas_set_high_iops_queue_affinity_hint (struct megasas_instance *instance) +megasas_set_high_iops_queue_affinity_and_hint (struct megasas_instance *instance) {int i; -int local_numa_node; +unsigned int irq; +const struct cpumask *mask;if (instance->perf_mode ==MR_BALANCED_PERF_MODE ) { - local_numa_node =dev_to_node (&instance->pdev->dev); + mask =cpumask_of_node (dev_to_node (&instance->pdev->dev)); -for (i =0 ; i < instance->low_latency_index_start; i++) -irq_set_affinity_hint (pci_irq_vector (instance->pdev, i), -cpumask_of_node (local_numa_node)); +for (i =0 ; i < instance->low_latency_index_start; i++) { + irq =pci_irq_vector (instance->pdev, i); +irq_set_affinity_and_hint (irq, mask); + } } }
@@ -5996,7 +5999,7 @@ megasas_alloc_irq_vectors(struct megasas_instance *instance) instance->msix_vectors =0 ;if (instance->smp_affinity_enable) -megasas_set_high_iops_queue_affinity_hint (instance); +megasas_set_high_iops_queue_affinity_and_hint (instance); }/**
Signature · 1 line
2.27.0
Re: [PATCH v5 04/14] scsi: megaraid_sas: Use irq_set_affinity_and_hint
Quoted 21 lines · Nitesh Narayan Lal
The driver uses
irq_set_affinity_hint()specifically for the high IOPS queue interrupts for two purposes:- To set the
affinity_hintwhich 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 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 theirq_set_affinity_hint()with the new interfaceirq_set_affinity_and_hint()where the provided mask needs to be applied as the affinity andaffinity_hintpointer needs to be set and replace withirq_update_affinity_hint()where onlyaffinity_hintneeds to be updated.
Quoted 5 lines
Change the
megasas_set_high_iops_queue_affinity_hintfunction name tomegasas_set_high_iops_queue_affinity_and_hintto clearly indicate that the function is setting both affinity andaffinity_hint.Signed-off-by Nitesh Narayan Lal <[email protected]>
Looks good.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4209 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20210806/513d1083/attachment.p7s>
PATCH v5 5/14 scsi: mpt3sas: Use irq_set_affinity_and_hint
In reply to Nitesh Narayan LalThe 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.
--- drivers/scsi/mpt3sas/mpt3sas_base.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/scsi/mpt3sas/mpt3sas_base.c +10 -11
@@ -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); } }
Signature · 1 line
2.27.0
Re: [PATCH v5 05/14] scsi: mpt3sas: Use irq_set_affinity_and_hint
Quoted 14 lines · Nitesh Narayan Lal
The driver uses
irq_set_affinity_hint()specifically for the high IOPS queue interrupts for two purposes:- To set the
affinity_hintwhich 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.
Quoted 7 lines
To remove this side effect
irq_set_affinity_hint()has been marked as deprecated and new interfaces have been introduced. Hence, replace theirq_set_affinity_hint()with the new interfaceirq_set_affinity_and_hint()where the provided mask needs to be applied as the affinity andaffinity_hintpointer needs to be set and replace withirq_update_affinity_hint()where onlyaffinity_hintneeds to be updated.
Changes looks good and also verified that the high iops queue's IRQs are affinitied to local numa node.
Quoted 66 lines
Signed-off-by Nitesh Narayan Lal <[email protected]>--- drivers/scsi/mpt3sas/mpt3sas_base.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)drivers/scsi/mpt3sas/mpt3sas_base.c +10
-12@@ -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); } } --
Quoted 2 lines
2.27.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4218 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20210806/eb95c8f7/attachment.p7s>
PATCH v5 6/14 RDMA/irdma: Use irq_update_affinity_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() to update the affinity_hint mask that is consumed by the userspace to distribute the interrupts. However, under the hood irq_set_affinity_hint() also applies the provided cpumask (if not NULL) as the affinity for the given interrupt which 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_update_affinity_hint() that only updates the affinity_hint pointer.
--- drivers/infiniband/hw/irdma/hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/irdma/hw.c +2 -2
@@ -537,7 +537,7 @@ static void irdma_destroy_irq(struct irdma_pci_f *rf,struct irdma_sc_dev *dev = &rf->sc_dev; dev->irq_ops->irdma_dis_irq (dev, msix_vec->idx); -irq_set_affinity_hint (msix_vec->irq,NULL ); +irq_update_affinity_hint (msix_vec->irq,NULL );free_irq (msix_vec->irq, dev_id); }
@@ -1087,7 +1087,7 @@ irdma_cfg_ceq_vector(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, }cpumask_clear (&msix_vec->mask);cpumask_set_cpu (msix_vec->cpu_affinity, &msix_vec->mask); -irq_set_affinity_hint (msix_vec->irq, &msix_vec->mask); +irq_update_affinity_hint (msix_vec->irq, &msix_vec->mask);if (status) {ibdev_dbg (&rf->iwdev->ibdev,"ERR: ceq irq config fail\n" );return IRDMA_ERR_CFG ;
Signature · 1 line
2.27.0
RE: [PATCH v5 06/14] RDMA/irdma: Use irq_update_affinity_hint
Quoted 76 lines
-----Original Message-----
From: Nitesh Narayan Lal <[email protected]>
Sent: Tuesday, July 20, 2021 6:26 PM
To: linux-kernel at vger.kernel.org; linux-scsi at vger.kernel.org; intel-wired- lan at lists.osuosl.org; netdev at vger.kernel.org; linux-api at vger.kernel.org; linux-pci at vger.kernel.org; tglx at linutronix.de; Brandeburg, Jesse <[email protected]>; robin.murphy at arm.com;
mtosatti at redhat.com; mingo at kernel.org; jbrandeb at kernel.org; frederic at kernel.org; juri.lelli at redhat.com; abelits at marvell.com; bhelgaas at google.com; rostedt at goodmis.org; peterz at infradead.org; davem at davemloft.net; akpm at linux-foundation.org; sfr at canb.auug.org.au; stephen at networkplumber.org; rppt at linux.vnet.ibm.com; chris.friesen at windriver.com; maz at kernel.org; nhorman at tuxdriver.com; pjwaskiewicz at gmail.com; sassmann at redhat.com; thenzl at redhat.com; kashyap.desai at broadcom.com; sumit.saxena at broadcom.com; shivasharan.srikanteshwara at broadcom.com;
sathya.prakash at broadcom.com; sreekanth.reddy at broadcom.com; suganath-prabu.subramani at broadcom.com; james.smart at broadcom.com; dick.kennedy at broadcom.com; jkc at redhat.com; Latif, Faisal <[email protected]>; Saleem, Shiraz <[email protected]>; tariqt at nvidia.com; ahleihel at redhat.com; kheib at redhat.com; borisp at nvidia.com; saeedm at nvidia.com; benve at cisco.com; govind at gmx.com; jassisinghbrar at gmail.com;
ajit.khaparde at broadcom.com; sriharsha.basavapatna at broadcom.com; somnath.kotur at broadcom.com; nilal at redhat.com; Nikolova, Tatyana E <[email protected]>; Ismail, Mustafa <[email protected]>; ahs3 at redhat.com; leonro at nvidia.com; chandrakanth.patil at broadcom.com; bjorn.andersson at linaro.org; chunkuang.hu at kernel.org; yongqiang.niu at mediatek.com; baolin.wang7 at gmail.com; poros at redhat.com; minlei at redhat.com; emilne at redhat.com; jejb at linux.ibm.com; martin.petersen at oracle.com;_govindat gmx.com; kabel at kernel.org; viresh.kumar at linaro.org; Tushar.Khandelwal at arm.com; kuba at kernel.org
Subject: [PATCH v5 06/14] RDMA/irdma: Useirq_update_affinity_hintThe driver uses
irq_set_affinity_hint()to update theaffinity_hintmask that is consumed by the userspace to distribute the interrupts. However, under the hoodirq_set_affinity_hint()also applies the provided cpumask (if not NULL) as the affinity for the given interrupt which 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 theirq_set_affinity_hint()with the new interfaceirq_update_affinity_hint()that only updates theaffinity_hintpointer.Signed-off-by Nitesh Narayan Lal <[email protected]>--- drivers/infiniband/hw/irdma/hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/hw/irdma/hw.c +2
-2@@ -537,7 +537,7 @@ static void irdma_destroy_irq(struct irdma_pci_f *rf,struct irdma_sc_dev *dev = &rf->sc_dev; dev->irq_ops->irdma_dis_irq (dev, msix_vec->idx); -irq_set_affinity_hint (msix_vec->irq,NULL ); +irq_update_affinity_hint (msix_vec->irq,NULL );free_irq (msix_vec->irq, dev_id); }@@ -1087,7 +1087,7 @@ irdma_cfg_ceq_vector(struct irdma_pci_f *rf, struct irdma_ceq *iwceq, }cpumask_clear (&msix_vec->mask);cpumask_set_cpu (msix_vec->cpu_affinity, &msix_vec->mask); -irq_set_affinity_hint (msix_vec->irq, &msix_vec->mask); +irq_update_affinity_hint (msix_vec->irq, &msix_vec->mask);if (status) {ibdev_dbg (&rf->iwdev->ibdev,"ERR: ceq irq config fail\n" );
Quoted 3 lines
return
IRDMA_ERR_CFG;
--
2.27.0
PATCH v5 7/14 enic: Use irq_update_affinity_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() to update the affinity_hint mask that is consumed by the userspace to distribute the interrupts. However, under the hood irq_set_affinity_hint() also applies the provided cpumask (if not NULL) as the affinity for the given interrupt which 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_update_affinity_hint() that only updates the affinity_hint pointer.
--- drivers/net/ethernet/cisco/enic/enic_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/cisco/enic/enic_main.c +4 -4
@@ -150,10 +150,10 @@ static void enic_set_affinity_hint(struct enic *enic) !cpumask_available (enic->msix[i].affinity_mask) || cpumask_empty(enic->msix[i].affinity_mask)) continue; - err =irq_set_affinity_hint (enic->msix_entry[i].vector, - enic->msix[i].affinity_mask); + err =irq_update_affinity_hint (enic->msix_entry[i].vector, + enic->msix[i].affinity_mask);if (err) -netdev_warn (enic->netdev,"irq_set_affinity_hint failed, err %d\n" , +netdev_warn (enic->netdev,"irq_update_affinity_hint failed, err %d\n" , err); }
@@ -173,7 +173,7 @@ static void enic_unset_affinity_hint(struct enic *enic)int i;for (i =0 ; i < enic->intr_count; i++) -irq_set_affinity_hint (enic->msix_entry[i].vector,NULL ); +irq_update_affinity_hint (enic->msix_entry[i].vector,NULL ); } static int enic_udp_tunnel_set_port(struct net_device *netdev,
Signature · 1 line
2.27.0
RE: [PATCH v5 07/14] enic: Use irq_update_affinity_hint
Quoted 40 lines
-----Original Message-----
From: Nitesh Narayan Lal <[email protected]>
Sent: Tuesday, July 20, 2021 4:26 PM
To: linux-kernel at vger.kernel.org; linux-scsi at vger.kernel.org; intel-wired- lan at lists.osuosl.org; netdev at vger.kernel.org; linux-api at vger.kernel.org; linux-pci at vger.kernel.org; tglx at linutronix.de; jesse.brandeburg at intel.com; robin.murphy at arm.com; mtosatti at redhat.com; mingo at kernel.org; jbrandeb at kernel.org; frederic at kernel.org; juri.lelli at redhat.com; abelits at marvell.com; bhelgaas at google.com; rostedt at goodmis.org; peterz at infradead.org; davem at davemloft.net; akpm at linux-foundation.org; sfr at canb.auug.org.au; stephen at networkplumber.org;
rppt at linux.vnet.ibm.com; chris.friesen at windriver.com; maz at kernel.org; nhorman at tuxdriver.com; pjwaskiewicz at gmail.com;
sassmann at redhat.com; thenzl at redhat.com;
kashyap.desai at broadcom.com; sumit.saxena at broadcom.com; shivasharan.srikanteshwara at broadcom.com;
sathya.prakash at broadcom.com; sreekanth.reddy at broadcom.com; suganath-prabu.subramani at broadcom.com; james.smart at broadcom.com; dick.kennedy at broadcom.com; jkc at redhat.com; faisal.latif at intel.com; shiraz.saleem at intel.com; tariqt at nvidia.com; ahleihel at redhat.com; kheib at redhat.com; borisp at nvidia.com; saeedm at nvidia.com; Christian Benvenuti (benve) <[email protected]>; govind at gmx.com;
jassisinghbrar at gmail.com; ajit.khaparde at broadcom.com; sriharsha.basavapatna at broadcom.com; somnath.kotur at broadcom.com; nilal at redhat.com; tatyana.e.nikolova at intel.com; mustafa.ismail at intel.com; ahs3 at redhat.com; leonro at nvidia.com; chandrakanth.patil at broadcom.com; bjorn.andersson at linaro.org; chunkuang.hu at kernel.org; yongqiang.niu at mediatek.com; baolin.wang7 at gmail.com;
poros at redhat.com; minlei at redhat.com; emilne at redhat.com;
jejb at linux.ibm.com; martin.petersen at oracle.com;_govindat gmx.com; kabel at kernel.org; viresh.kumar at linaro.org; Tushar.Khandelwal at arm.com; kuba at kernel.org
Subject: [PATCH v5 07/14] enic: Useirq_update_affinity_hintThe driver uses
irq_set_affinity_hint()to update theaffinity_hintmask that is consumed by the userspace to distribute the interrupts. However, under the hoodirq_set_affinity_hint()also applies the provided cpumask (if not NULL) as the affinity for the given interrupt which is an undocumented side effect.
Quoted 6 lines
To remove this side effect
irq_set_affinity_hint()has been marked as deprecated and new interfaces have been introduced. Hence, replace theirq_set_affinity_hint()with the new interfaceirq_update_affinity_hint()that only updates theaffinity_hintpointer.Signed-off-by Nitesh Narayan Lal <[email protected]>
Thanks Nitesh for the patch.
PATCH v5 8/14 be2net: Use irq_update_affinity_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() to update the affinity_hint mask that is consumed by the userspace to distribute the interrupts. However, under the hood irq_set_affinity_hint() also applies the provided cpumask (if not NULL) as the affinity for the given interrupt which 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_update_affinity_hint() that only updates the affinity_hint pointer.
--- drivers/net/ethernet/emulex/benet/be_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/emulex/benet/be_main.c +2 -2
@@ -3491,7 +3491,7 @@ static int be_msix_register(struct be_adapter *adapter)if (status) goto err_msix; -irq_set_affinity_hint (vec, eqo->affinity_mask); +irq_update_affinity_hint (vec, eqo->affinity_mask); }return 0 ;
@@ -3552,7 +3552,7 @@ static void be_irq_unregister(struct be_adapter *adapter)/* MSIx */ for_all_evt_queues(adapter, eqo, i) { vec =be_msix_vec_get (adapter, eqo); -irq_set_affinity_hint (vec,NULL ); +irq_update_affinity_hint (vec,NULL );free_irq (vec, eqo); }
Signature · 1 line
2.27.0
PATCH v5 9/14 ixgbe: Use irq_update_affinity_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() to update the affinity_hint mask that is consumed by the userspace to distribute the interrupts. However, under the hood irq_set_affinity_hint() also applies the provided cpumask (if not NULL) as the affinity for the given interrupt which 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_update_affinity_hint() that only updates the affinity_hint pointer.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +5 -5
@@ -3241,8 +3241,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter)/* If Flow Director is enabled, set interrupt affinity */ if (adapter->flags &IXGBE_FLAG_FDIR_HASH_CAPABLE ) {/* assign the mask for this irq */ -irq_set_affinity_hint (entry->vector, - &q_vector->affinity_mask); +irq_update_affinity_hint (entry->vector, + &q_vector->affinity_mask); } }
@@ -3258,8 +3258,8 @@ static int ixgbe_request_msix_irqs(struct ixgbe_adapter *adapter) free_queue_irqs:while (vector) { vector--; -irq_set_affinity_hint (adapter->msix_entries[vector].vector, -NULL ); +irq_update_affinity_hint (adapter->msix_entries[vector].vector, +NULL );free_irq (adapter->msix_entries[vector].vector, adapter->q_vector[vector]); }
@@ -3392,7 +3392,7 @@ static void ixgbe_free_irq(struct ixgbe_adapter *adapter)continue ;/* clear the affinity_mask in the IRQ descriptor */ -irq_set_affinity_hint (entry->vector,NULL ); +irq_update_affinity_hint (entry->vector,NULL );free_irq (entry->vector, q_vector); }
Signature · 1 line
2.27.0
PATCH v5 10/14 mailbox: Use irq_update_affinity_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() to:
- Set the affinity_hint which is consumed by the userspace for distributing the interrupts
- Enforce affinity
As per commit 6ac17fe8c14a ("mailbox: bcm-flexrm-mailbox: Set IRQ affinity hint for FlexRM ring IRQs") the latter is done to ensure that the FlexRM ring interrupts are evenly spread across all available CPUs. However, since commit a0c9259dc4e1 ("irq/matrix: Spread interrupts on allocation") the spreading of interrupts is dynamically performed at the time of allocation. Hence, there is no need for the drivers to enforce their own affinity for the spreading of interrupts.
Also, irq_set_affinity_hint() applying the provided cpumask as an affinity 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_update_affinity_hint() that only sets the affinity_hint pointer.
--- drivers/mailbox/bcm-flexrm-mailbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mailbox/bcm-flexrm-mailbox.c +2 -2
@@ -1298,7 +1298,7 @@ static int flexrm_startup(struct mbox_chan *chan) val = (num_online_cpus () < val) ? val /num_online_cpus () :1 ;cpumask_set_cpu ((ring->num / val) %num_online_cpus (), &ring->irq_aff_hint); - ret =irq_set_affinity_hint (ring->irq, &ring->irq_aff_hint); + ret =irq_update_affinity_hint (ring->irq, &ring->irq_aff_hint);if (ret) { dev_err(ring->mbox->dev, "failed to set IRQ affinity hint for ring%d\n",
@@ -1425,7 +1425,7 @@ static void flexrm_shutdown(struct mbox_chan *chan)/* Release IRQ */ if (ring->irq_requested) { -irq_set_affinity_hint (ring->irq,NULL ); +irq_update_affinity_hint (ring->irq,NULL );free_irq (ring->irq, ring); ring->irq_requested = false; }
Signature · 1 line
2.27.0
Re: [PATCH v5 10/14] mailbox: Use irq_update_affinity_hint
Quoted 43 lines · Nitesh Narayan Lal
The driver uses
irq_set_affinity_hint()to:- Set the
affinity_hintwhich is consumed by the userspace for distributing the interrupts- Enforce affinity
As per commit
6ac17fe8c14a("mailbox: bcm-flexrm-mailbox: Set IRQ affinity hint for FlexRM ring IRQs") the latter is done to ensure that the FlexRM ring interrupts are evenly spread across all available CPUs. However, since commita0c9259dc4e1("irq/matrix: Spread interrupts on allocation") the spreading of interrupts is dynamically performed at the time of allocation. Hence, there is no need for the drivers to enforce their own affinity for the spreading of interrupts.Also,
irq_set_affinity_hint()applying the provided cpumask as an affinity for the interrupt is an undocumented side effect. To remove this side effectirq_set_affinity_hint()has been marked as deprecated and new interfaces have been introduced. Hence, replace theirq_set_affinity_hint()with the new interfaceirq_update_affinity_hint()that only sets theaffinity_hintpointer.Signed-off-by Nitesh Narayan Lal <[email protected]>--- drivers/mailbox/bcm-flexrm-mailbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mailbox/bcm-flexrm-mailbox.c +1
-1@@ -1298,7 +1298,7 @@ static int flexrm_startup(struct mbox_chan *chan) val = (num_online_cpus () < val) ? val /num_online_cpus () :1 ;cpumask_set_cpu ((ring->num / val) %num_online_cpus (), &ring->irq_aff_hint); - ret =irq_set_affinity_hint (ring->irq, &ring->irq_aff_hint); + ret =irq_update_affinity_hint (ring->irq, &ring->irq_aff_hint);if (ret) { dev_err(ring->mbox->dev, "failed to set IRQ affinity hint for ring%d\n",
drivers/mailbox/bcm-flexrm-mailbox.c static void flexrm_shutdown(struct mbox_chan *chan) · line 1431
Quoted 8 lines
drivers/mailbox/bcm-flexrm-mailbox.c +1
-1@@ -1425,7 +1425,7 @@ static void flexrm_shutdown(struct mbox_chan *chan)/* Release IRQ */ if (ring->irq_requested) { -irq_set_affinity_hint (ring->irq,NULL ); +irq_update_affinity_hint (ring->irq,NULL );free_irq (ring->irq, ring); ring->irq_requested = false; }
Seems ok to me. But I don't have the h/w to test.
cheers.
PATCH v5 11/14 scsi: lpfc: Use irq_set_affinity
In reply to Nitesh Narayan LalThe 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.
--- drivers/scsi/lpfc/lpfc_init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +1 -3
@@ -11455,7 +11455,7 @@ lpfc_irq_set_aff(struct lpfc_hba_eq_hdl *eqhdl, unsigned int cpu)cpumask_clear (&eqhdl->aff_mask);cpumask_set_cpu (cpu, &eqhdl->aff_mask);irq_set_status_flags (eqhdl->irq,IRQ_NO_BALANCING ); -irq_set_affinity_hint (eqhdl->irq, &eqhdl->aff_mask); +irq_set_affinity (eqhdl->irq, &eqhdl->aff_mask); }/**
@@ -11744,7 +11744,6 @@ lpfc_sli4_enable_msix(struct lpfc_hba *phba)for (--index; index >=0 ; index--) { eqhdl =lpfc_get_eq_hdl (index);lpfc_irq_clear_aff (eqhdl); -irq_set_affinity_hint (eqhdl->irq,NULL );free_irq (eqhdl->irq, eqhdl); }
@@ -11905,7 +11904,6 @@ lpfc_sli4_disable_intr(struct lpfc_hba *phba)for (index =0 ; index < phba->cfg_irq_chann; index++) { eqhdl =lpfc_get_eq_hdl (index);lpfc_irq_clear_aff (eqhdl); -irq_set_affinity_hint (eqhdl->irq,NULL );free_irq (eqhdl->irq, eqhdl); } }else {
Signature · 1 line
2.27.0
Re: [PATCH v5 11/14] scsi: lpfc: Use irq_set_affinity
Quoted 17 lines · Nitesh Narayan Lal
The driver uses
irq_set_affinity_hintto 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 effectirq_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 useirq_set_affinity_hint()to set the cpu affinity and disable user-space rebalancing."
we don't really need to set theaffinity_hintas user-space rebalancing for the lpfc interrupts is not desired.
Quoted 8 lines
Hence, replace the
irq_set_affinity_hint()withirq_set_affinity()which only applies the affinity for the interrupts.Signed-off-by Nitesh Narayan Lal <[email protected]>--- drivers/scsi/lpfc/lpfc_init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Looks good. Thanks
-- james
PATCH v5 12/14 hinic: Use irq_set_affinity_and_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() to:
- Set the affinity_hint which is consumed by the userspace for distributing the interrupts
- Enforce affinity
As per commit 352f58b0d9f2 ("net-next/hinic: Set Rxq irq to specific cpu for NUMA"), the hinic driver enforces its own affinity to bind IRQs to the local NUMA node. However, irq_set_affinity_hint() applying the provided cpumask as an affinity 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.
--- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_rx.c +2 -2
@@ -548,7 +548,7 @@ static int rx_request_irq(struct hinic_rxq *rxq) goto err_req_irq;cpumask_set_cpu (qp->q_id %num_online_cpus (), &rq->affinity_mask); - err =irq_set_affinity_hint (rq->irq, &rq->affinity_mask); + err =irq_set_affinity_and_hint (rq->irq, &rq->affinity_mask);if (err) goto err_irq_affinity;
@@ -565,7 +565,7 @@ static void rx_free_irq(struct hinic_rxq *rxq) {struct hinic_rq *rq = rxq->rq; -irq_set_affinity_hint (rq->irq,NULL ); +irq_update_affinity_hint (rq->irq,NULL );free_irq (rq->irq, rxq);rx_del_napi (rxq); }
Signature · 1 line
2.27.0
PATCH v5 13/14 net/mlx5: Use irq_set_affinity_and_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() to update the affinity_hint mask that is consumed by the userspace to distribute the interrupts and to apply the provided mask as the affinity for the mlx5 interrupts. However, irq_set_affinity_hint() applying the provided cpumask as an affinity 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.
--- drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c +4 -4
@@ -144,11 +144,11 @@ static void irq_release(struct kref *kref)struct mlx5_irq_pool *pool = irq->pool;xa_erase (&pool->irqs, irq->index); -/* free_irq requires that affinity and rmap will be cleared +/* free_irq requires that affinity_hint and rmap will be cleared * before calling it. This is why there is asymmetry with set_rmap * which should be called after alloc_irq but before request_irq. */ -irq_set_affinity_hint (irq->irqn,NULL ); +irq_update_affinity_hint (irq->irqn,NULL );free_cpumask_var (irq->mask);free_irq (irq->irqn, &irq->nh);kfree (irq);
@@ -283,7 +283,7 @@ static struct mlx5_irq *irq_pool_create_irq(struct mlx5_irq_pool *pool,if (IS_ERR (irq))return irq;cpumask_copy (irq->mask, affinity); -irq_set_affinity_hint (irq->irqn, irq->mask); +irq_set_affinity_and_hint (irq->irqn, irq->mask);return irq; }
@@ -364,7 +364,7 @@ irq_pool_request_vector(struct mlx5_irq_pool *pool, int vecidx,if (IS_ERR (irq) || !affinity) goto unlock;cpumask_copy (irq->mask, affinity); -irq_set_affinity_hint (irq->irqn, irq->mask); +irq_set_affinity_and_hint (irq->irqn, irq->mask); unlock:mutex_unlock (&pool->lock);return irq;
Signature · 1 line
2.27.0
PATCH v5 14/14 net/mlx4: Use irq_update_affinity_hint
In reply to Nitesh Narayan LalThe driver uses irq_set_affinity_hint() to update the affinity_hint mask that is consumed by the userspace to distribute the interrupts. However, under the hood irq_set_affinity_hint() also applies the provided cpumask (if not NULL) as the affinity for the given interrupt which 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_update_affinity_hint() that only updates the affinity_hint pointer.
--- drivers/net/ethernet/mellanox/mlx4/eq.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx4/eq.c +3 -5
@@ -244,9 +244,9 @@ static void mlx4_set_eq_affinity_hint(struct mlx4_priv *priv, int vec) cpumask_empty(eq->affinity_mask))return ; - hint_err =irq_set_affinity_hint (eq->irq, eq->affinity_mask); + hint_err =irq_update_affinity_hint (eq->irq, eq->affinity_mask);if (hint_err) - mlx4_warn(dev, "irq_set_affinity_hint failed, err %d\n", hint_err); + mlx4_warn(dev, "irq_update_affinity_hint failed, err %d\n", hint_err); }#endif
@@ -1123,9 +1123,7 @@ static void mlx4_free_irqs(struct mlx4_dev *dev)for (i =0 ; i < dev->caps.num_comp_vectors +1 ; ++i)if (eq_table->eq[i].have_irq) {free_cpumask_var (eq_table->eq[i].affinity_mask); -#if defined(CONFIG_SMP ) -irq_set_affinity_hint (eq_table->eq[i].irq,NULL ); -#endif +irq_update_affinity_hint (eq_table->eq[i].irq,NULL );free_irq (eq_table->eq[i].irq, eq_table->eq + i); eq_table->eq[i].have_irq =0 ; }
Signature · 1 line
2.27.0
Quoted 11 lines · Nitesh Narayan Lal
The drivers currently rely on
irq_set_affinity_hint()to either set theaffinity_hintthat is consumed by the userspace and/or to enforce a custom affinity.
irq_set_affinity_hint()as the name suggests is originally introduced to only set theaffinity_hintto help the userspace in guiding the interrupts and not the affinity itself. However, since the commit
e2e64a932556"genirq: Set initial affinity inirq_set_affinity_hint()"
[...]
Quoted 17 lines
drivers/infiniband/hw/irdma/hw.c | 4 +- drivers/mailbox/bcm-flexrm-mailbox.c | 4 +- drivers/net/ethernet/cisco/enic/enic_main.c | 8 +-- drivers/net/ethernet/emulex/benet/be_main.c | 4 +- drivers/net/ethernet/huawei/hinic/hinic_rx.c | 4 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 8 +-- drivers/net/ethernet/intel/iavf/iavf_main.c | 8 +-- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 10 ++-- drivers/net/ethernet/mellanox/mlx4/eq.c | 8 ++- .../net/ethernet/mellanox/mlx5/core/pci_irq.c | 8 +-- drivers/scsi/lpfc/lpfc_init.c | 4 +- drivers/scsi/megaraid/megaraid_sas_base.c | 27 +++++----- drivers/scsi/mpt3sas/mpt3sas_base.c | 21 ++++---- include/linux/interrupt.h | 53 ++++++++++++++++++- kernel/irq/manage.c | 8 +-- 15 files changed, 114 insertions(+), 65 deletions(-)
Quoted 3 lines
--
Gentle ping.
Any comments on the following patches:
genirq: Provide new interfaces for affinity hints
scsi: megaraid_sas: Use irq_set_affinity_and_hint
scsi: mpt3sas: Use irq_set_affinity_and_hint
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?
Signature · 2 lines
Thanks Nitesh
Nitesh,
Quoted 5 lines
Gentle ping.
Any comments on the following patches:scsi:
megaraid_sas: Useirq_set_affinity_and_hint
scsi: mpt3sas: Useirq_set_affinity_and_hint
Sumit and Sreekanth: Please review.
Thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 10 lines · Martin K. Petersen
Nitesh,
Quoted 5 lines
Gentle ping.
Any comments on the following patches:scsi:
megaraid_sas: Useirq_set_affinity_and_hint
scsi: mpt3sas: Useirq_set_affinity_and_hint
Quoted 7 lines
Sumit and Sreekanth: Please review.
Thanks!
--
Martin K. Petersen Oracle Linux Engineering
Thanks, Martin, Sumit & Sreekanth for the help.
--
Nitesh
Quoted 7 lines · Nitesh Lal
Quoted 5 lines · Nitesh Narayan Lal
The drivers currently rely on
irq_set_affinity_hint()to either set theaffinity_hintthat is consumed by the userspace and/or to enforce a custom affinity.
[...]
Quoted 12 lines
Gentle ping.
Any comments on the following patches:genirq: Provide new interfaces for affinity hints
scsi:megaraid_sas: Useirq_set_affinity_and_hint
scsi: mpt3sas: Useirq_set_affinity_and_hint
enic: Useirq_update_affinity_hint
be2net: Useirq_update_affinity_hint
mailbox: Useirq_update_affinity_hint
hinic: Useirq_set_affinity_and_hint
Quoted 2 lines
or any other patches?
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.
Signature · 2 lines
Thanks Nitesh
Quoted 10 lines · Nitesh Lal
Quoted 7 lines · Nitesh Lal
Quoted 5 lines · Nitesh Narayan Lal
The drivers currently rely on
irq_set_affinity_hint()to either set theaffinity_hintthat is consumed by the userspace and/or to enforce a custom affinity.
[...]
Quoted 11 lines
Any comments on the following patches:
enic: Use
irq_update_affinity_hint
be2net: Useirq_update_affinity_hint
mailbox: Useirq_update_affinity_hint
hinic: Useirq_set_affinity_and_hintor 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
Quoted 27 lines · Nitesh Lal
Quoted 10 lines · Nitesh Lal
Quoted 7 lines · Nitesh Lal
Quoted 5 lines · Nitesh Narayan Lal
The drivers currently rely on
irq_set_affinity_hint()to either set theaffinity_hintthat is consumed by the userspace and/or to enforce a custom affinity.[...]
Quoted 11 lines
Any comments on the following patches:
enic: Use
irq_update_affinity_hint
be2net: Useirq_update_affinity_hint
mailbox: Useirq_update_affinity_hint
hinic: Useirq_set_affinity_and_hintor any other patches?
Any help in testing will also be very useful.
Quoted 7 lines
Gentle ping.
Any comments on the following patches:be2net: Use
irq_update_affinity_hint
hinic: Useirq_set_affinity_and_hintor any other patches?
Also, I have been trying to reach Bin Luo who maintains the hinic driver but it seems his email ID has changed so if someone else can help in reviewing/testing the hinic patch, it would be really helpful.
Signature · 2 lines
Thanks Nitesh