Skip to content

genirq: Cleanup the abuse of irq_set_affinity_hint()

Nitesh Narayan Lal linux-pci linux-scsi lkml netdev 6 versions – Applied

Status from this message: The following commit has been merged into the irq/core branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest14 patches 6 repliesApplied
  2. v514 patches 13 repliesSuperseded
  3. v414 patches 1 replySuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v314 patches9 repliesSuperseded
v214 patches6 repliesSuperseded
v114 patches7 repliesSuperseded

Patches in v6 Applied

#Subject and filesSizeRepliesApplied
1/14genirq: Provide new interfaces for affinity hintsinclude/linux/interrupt.h kernel/irq/manage.c+56 -50 replies
2/14iavf: Use irq_update_affinity_hintdrivers/net/ethernet/intel/iavf/iavf_main.c+4 -40 replies
3/14i40e: Use irq_update_affinity_hintdrivers/net/ethernet/intel/i40e/i40e_main.c+4 -40 replies
4/14scsi: megaraid_sas: Use irq_set_affinity_and_hintdrivers/scsi/megaraid/megaraid_sas_base.c+15 -120 replies
5/14scsi: mpt3sas: Use irq_set_affinity_and_hintdrivers/scsi/mpt3sas/mpt3sas_base.c+10 -110 replies
6/14RDMA/irdma: Use irq_update_affinity_hintdrivers/infiniband/hw/irdma/hw.c+2 -20 replies
7/14enic: Use irq_update_affinity_hintdrivers/net/ethernet/cisco/enic/enic_main.c+4 -40 replies
8/14be2net: Use irq_update_affinity_hintdrivers/net/ethernet/emulex/benet/be_main.c+2 -20 replies
9/14ixgbe: Use irq_update_affinity_hintdrivers/net/ethernet/intel/ixgbe/ixgbe_main.c+5 -50 replies
10/14mailbox: Use irq_update_affinity_hintdrivers/mailbox/bcm-flexrm-mailbox.c+2 -20 replies
11/14scsi: lpfc: Use irq_set_affinitydrivers/scsi/lpfc/lpfc_init.c+1 -30 replies
12/14hinic: Use irq_set_affinity_and_hintdrivers/net/ethernet/huawei/hinic/hinic_rx.c+2 -20 replies
13/14net/mlx5: Use irq_set_affinity_and_hintdrivers/net/ethernet/mellanox/mlx5/core/pci_irq.c+4 -40 replies
14/14net/mlx4: Use irq_update_affinity_hintdrivers/net/ethernet/mellanox/mlx4/eq.c+3 -50 replies

Reviews trailers per patch

12 of 14 patches have a Reviewed-by or Acked-by.

PatchMing LeiJesse BrandeburgSreekanth ReddySumit SaxenaTatyana NikolovaChristian BenvenutiJassi BrarJames SmartLeon RomanovskyTariq Toukan
1/14R-b
2/14A-b
3/14A-b
4/14A-b
5/14R-b
6/14A-b
7/14R-b
8/14
9/14A-b
10/14A-b
11/14R-b
12/14
13/14R-b
14/14R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 10 reviewers.

Read the v6 thread

Cover letter [PATCH v6 00/14] 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.

The two patches in this series that still needs to be reviewed are:
be2net: Use irq_update_affinity_hint
hinic: Use irq_set_affinity_and_hint

any help there will be much appreciated.

Change from v5 [5]
------------------

- Rebased on top of the latest Linus's tree:
a9c9a6f741cd "Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi"
- Added reviewed-by/acked-by in the patches

Change from v4 [6]
------------------
- 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 [7].

Change from v3 [8]
------------------
- 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 [9]
------------------

- Rebased on top of 5.14-rc1 (Leon Romanovsky)
+ After discussion with Leon [10], 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 [11]
------------------
- 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/[email protected]/
[2] https://lore.kernel.org/linux-pci/[email protected]/
[3] https://lore.kernel.org/linux-arm-kernel/[email protected]/
[4] https://lore.kernel.org/patchwork/patch/1434326/
[5] https://lore.kernel.org/netdev/[email protected]/T/
[6] https://lore.kernel.org/lkml/[email protected]/
[7] https://lore.kernel.org/linux-arm-kernel/[email protected]/
[8] https://lore.kernel.org/linux-scsi/[email protected]/
[9] https://lore.kernel.org/lkml/[email protected]/
[10] https://lore.kernel.org/lkml/YO0eKv2GJcADQTHH@unreal/
[11] https://lore.kernel.org/linux-scsi/[email protected]/

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(-)