net: move aRFS rmap management and CPU affinity to core
authorAhmed Zaki <ahmed.zaki@intel.com>
Mon, 24 Feb 2025 23:22:22 +0000 (16:22 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 27 Feb 2025 03:51:37 +0000 (19:51 -0800)
commitbd7c00605ee0cf0bf27764d5da0b948d8004229e
tree50d5835e8d090080945ebbf3d1cb07f5b155ccfc
parent28d68d396a1cd21591e8c6d74afbde33a7ea107e
net: move aRFS rmap management and CPU affinity to core

A common task for most drivers is to remember the user-set CPU affinity
to its IRQs. On each netdev reset, the driver should re-assign the user's
settings to the IRQs. Unify this task across all drivers by moving the CPU
affinity to napi->config.

However, to move the CPU affinity to core, we also need to move aRFS
rmap management since aRFS uses its own IRQ notifiers.

For the aRFS, add a new netdev flag "rx_cpu_rmap_auto". Drivers supporting
aRFS should set the flag via netif_enable_cpu_rmap() and core will allocate
and manage the aRFS rmaps. Freeing the rmap is also done by core when the
netdev is freed. For better IRQ affinity management, move the IRQ rmap
notifier inside the napi_struct and add new notify.notify and
notify.release functions: netif_irq_cpu_rmap_notify() and
netif_napi_affinity_release().

Now we have the aRFS rmap management in core, add CPU affinity mask to
napi_config. To delegate the CPU affinity management to the core, drivers
must:
 1 - set the new netdev flag "irq_affinity_auto":
                                       netif_enable_irq_affinity(netdev)
 2 - create the napi with persistent config:
                                       netif_napi_add_config()
 3 - bind an IRQ to the napi instance: netif_napi_set_irq()

the core will then make sure to use re-assign affinity to the napi's
IRQ.

The default IRQ mask is set to one cpu starting from the closest NUMA.

Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
Link: https://patch.msgid.link/20250224232228.990783-2-ahmed.zaki@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/networking/scaling.rst
include/linux/cpu_rmap.h
include/linux/netdevice.h
lib/cpu_rmap.c
net/core/dev.c