mbox series

[v3,net-next,0/4] rtnetlink: Per-netns RTNL.

Message ID 20241004221031.77743-1-kuniyu@amazon.com (mailing list archive)
Headers show
Series rtnetlink: Per-netns RTNL. | expand

Message

Kuniyuki Iwashima Oct. 4, 2024, 10:10 p.m. UTC
rtnl_lock() is a "Big Kernel Lock" in the networking slow path and
serialised all rtnetlink requests until 4.13.

Since RTNL_FLAG_DOIT_UNLOCKED and RTNL_FLAG_DUMP_UNLOCKED have been
introduced in 4.14 and 6.9, respectively, rtnetlink message handlers
are ready to be converted to RTNL-less/free.

15 out of 44 dumpit()s have been converted to RCU so far, and the
progress is pretty good.  We can now dump various major network
resources without RTNL.

12 out of 87 doit()s have been converted, but most of the converted
doit()s are also on the reader side of RTNL; their message types are
RTM_GET*.

So, most of RTM_(NEW|DEL|SET)* operations are still serialised by RTNL.

For example, one of our services creates 2K netns and a small number
of network interfaces in each netns that require too many writer-side
rtnetlink requests, and setting up a single host takes 10+ minutes.

RTNL is still a huge pain for network configuration paths, and we need
more granular locking, given converting all doit()s would be unfeasible.

Actually, most RTNL users do not need to freeze multiple netns, and such
users can be protected by per-netns RTNL mutex.  The exceptions would be
RTM_NEWLINK, RTM_DELLINK, and RTM_SETLINK.  (See [0] and [1])

This series is the first step of the per-netns RTNL conversion that
gradually replaces rtnl_lock() with rtnl_net_lock(net) under
CONFIG_DEBUG_NET_SMALL_RTNL.

[0]: https://netdev.bots.linux.dev/netconf/2024/index.html
[1]: https://lpc.events/event/18/contributions/1959/


Changes:
  v3:
    * Patch 1 & 4 : Add Eric's tags
    * Patch 2 & 3 : Always evaludate net w/o CONFIG_DEBUG_NET_SMALL_RTNL

  v2: https://lore.kernel.org/netdev/20241002151240.49813-1-kuniyu@amazon.com/
    * Add revert of 464eb03c4a7c
    * Fix Kconfig dependency for arch with no lockdep support

  v1: https://lore.kernel.org/netdev/20240930202524.59357-1-kuniyu@amazon.com/


Kuniyuki Iwashima (4):
  Revert "rtnetlink: add guard for RTNL"
  rtnetlink: Add per-netns RTNL.
  rtnetlink: Add assertion helpers for per-netns RTNL.
  rtnetlink: Add ASSERT_RTNL_NET() placeholder for netdev notifier.

 include/linux/rtnetlink.h   |  69 +++++++++++++++++--
 include/net/net_namespace.h |   4 ++
 net/Kconfig.debug           |  15 +++++
 net/core/Makefile           |   1 +
 net/core/net_namespace.c    |   6 ++
 net/core/rtnetlink.c        |  70 +++++++++++++++++++
 net/core/rtnl_net_debug.c   | 131 ++++++++++++++++++++++++++++++++++++
 7 files changed, 289 insertions(+), 7 deletions(-)
 create mode 100644 net/core/rtnl_net_debug.c

Comments

patchwork-bot+netdevbpf@kernel.org Oct. 8, 2024, 1:30 p.m. UTC | #1
Hello:

This series was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Fri, 4 Oct 2024 15:10:27 -0700 you wrote:
> rtnl_lock() is a "Big Kernel Lock" in the networking slow path and
> serialised all rtnetlink requests until 4.13.
> 
> Since RTNL_FLAG_DOIT_UNLOCKED and RTNL_FLAG_DUMP_UNLOCKED have been
> introduced in 4.14 and 6.9, respectively, rtnetlink message handlers
> are ready to be converted to RTNL-less/free.
> 
> [...]

Here is the summary with links:
  - [v3,net-next,1/4] Revert "rtnetlink: add guard for RTNL"
    https://git.kernel.org/netdev/net-next/c/ec763c234d7f
  - [v3,net-next,2/4] rtnetlink: Add per-netns RTNL.
    https://git.kernel.org/netdev/net-next/c/76aed95319da
  - [v3,net-next,3/4] rtnetlink: Add assertion helpers for per-netns RTNL.
    https://git.kernel.org/netdev/net-next/c/844e5e7e656d
  - [v3,net-next,4/4] rtnetlink: Add ASSERT_RTNL_NET() placeholder for netdev notifier.
    https://git.kernel.org/netdev/net-next/c/03fa53485659

You are awesome, thank you!