mbox series

[net-next,0/3] Add support to do threaded napi busy poll

Message ID 20250102191227.2084046-1-skhawaja@google.com (mailing list archive)
Headers show
Series Add support to do threaded napi busy poll | expand

Message

Samiullah Khawaja Jan. 2, 2025, 7:12 p.m. UTC
Extend the already existing support of threaded napi poll to do continuous
busypolling.

This is used for doing continuous polling of napi to fetch descriptors from
backing RX/TX queues for low latency applications. Allow enabling of threaded
busypoll using netlink so this can be enabled on a set of dedicated napis for
low latency applications.

Currently threaded napi is only enabled at device level using sysfs. Add
support to enable/disable threaded mode for a napi individually. This can be
done using the netlink interface. Add `set_threaded` op in netlink spec that
allows setting the `threaded` attribute of a napi.

Extend the threaded attribute in napi struct to add an option to enable
continuous busy polling. Extend the netlink and sysfs interface to allow
enabled/disabling threaded busypolling at device or individual napi level.

Once threaded busypoll on a napi is enabled, depending on the application
requirements the polling thread can be moved to dedicated cores. We used this
for AF_XDP usecases to fetch packets from RX queues to reduce latency.

Samiullah Khawaja (3):
  Add support to set napi threaded for individual napi
  net: Create separate gro_flush helper function
  Extend napi threaded polling to allow kthread based busy polling

 Documentation/ABI/testing/sysfs-class-net     |   3 +-
 Documentation/netlink/specs/netdev.yaml       |  20 +++
 .../net/ethernet/atheros/atl1c/atl1c_main.c   |   2 +-
 include/linux/netdevice.h                     |  29 ++++-
 include/uapi/linux/netdev.h                   |   2 +
 net/core/dev.c                                | 122 ++++++++++++++----
 net/core/net-sysfs.c                          |   2 +-
 net/core/netdev-genl-gen.c                    |  13 ++
 net/core/netdev-genl-gen.h                    |   2 +
 net/core/netdev-genl.c                        |  37 ++++++
 tools/include/uapi/linux/netdev.h             |   2 +
 11 files changed, 205 insertions(+), 29 deletions(-)

Comments

Stanislav Fomichev Jan. 2, 2025, 9:30 p.m. UTC | #1
On 01/02, Samiullah Khawaja wrote:
> Extend the already existing support of threaded napi poll to do continuous
> busypolling.
> 
> This is used for doing continuous polling of napi to fetch descriptors from
> backing RX/TX queues for low latency applications. Allow enabling of threaded
> busypoll using netlink so this can be enabled on a set of dedicated napis for
> low latency applications.
> 
> Currently threaded napi is only enabled at device level using sysfs. Add
> support to enable/disable threaded mode for a napi individually. This can be
> done using the netlink interface. Add `set_threaded` op in netlink spec that
> allows setting the `threaded` attribute of a napi.
> 
> Extend the threaded attribute in napi struct to add an option to enable
> continuous busy polling. Extend the netlink and sysfs interface to allow
> enabled/disabling threaded busypolling at device or individual napi level.
> 
> Once threaded busypoll on a napi is enabled, depending on the application
> requirements the polling thread can be moved to dedicated cores. We used this
> for AF_XDP usecases to fetch packets from RX queues to reduce latency.

Joe recently added tools/testing/selftests/net/busy_poller.c, should we
extend it to cover your new threaded/non-thread busy/non-busy napi modes?
David Laight Jan. 2, 2025, 9:56 p.m. UTC | #2
On Thu,  2 Jan 2025 19:12:24 +0000
Samiullah Khawaja <skhawaja@google.com> wrote:

> Extend the already existing support of threaded napi poll to do continuous
> busypolling.
> 
> This is used for doing continuous polling of napi to fetch descriptors from
> backing RX/TX queues for low latency applications. Allow enabling of threaded
> busypoll using netlink so this can be enabled on a set of dedicated napis for
> low latency applications.
> 
> Currently threaded napi is only enabled at device level using sysfs. Add
> support to enable/disable threaded mode for a napi individually. This can be
> done using the netlink interface. Add `set_threaded` op in netlink spec that
> allows setting the `threaded` attribute of a napi.
> 
> Extend the threaded attribute in napi struct to add an option to enable
> continuous busy polling. Extend the netlink and sysfs interface to allow
> enabled/disabling threaded busypolling at device or individual napi level.
> 
> Once threaded busypoll on a napi is enabled, depending on the application
> requirements the polling thread can be moved to dedicated cores. We used this
> for AF_XDP usecases to fetch packets from RX queues to reduce latency.

I think it would be more generally useful to be able to set the priority
of the NAPI thread.
'busypolling' is just an extreme version of a high priority thread.

We've had to use threaded NAPI and a low SCHED_FIFO priority in order to
clear the RX queues without the softint code locking out a other SCHED_FIFO
user threads for 20ms+.
That is currently rather a pain to setup.

	David
Jakub Kicinski Jan. 3, 2025, 12:47 a.m. UTC | #3
On Thu,  2 Jan 2025 19:12:24 +0000 Samiullah Khawaja wrote:
> Extend the already existing support of threaded napi poll to do continuous
> busypolling.
> 
> This is used for doing continuous polling of napi to fetch descriptors from
> backing RX/TX queues for low latency applications. Allow enabling of threaded
> busypoll using netlink so this can be enabled on a set of dedicated napis for
> low latency applications.

This is lacking clear justification and experimental results
vs doing the same thing from user space.

I'd also appreciate if Google could share the experience and results
of using basic threaded NAPI _in production_.