Skip to content

rtnetlink: Per-netns RTNL.

Kuniyuki Iwashima netdev 3 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 5 repliesApplied 4/4
  2. v24 patches 9 repliesSuperseded
  3. v13 patches 2 repliesSuperseded

Changes in v3 from the cover letter

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

Patches in v3 All 4 applied

#Subject and filesSizeRepliesApplied
1/4Revert "rtnetlink: add guard for RTNL"include/linux/rtnetlink.h+0 -30 repliesApplied
2/4rtnetlink: Add per-netns RTNL.include/linux/rtnetlink.h include/net/net_namespace.h net/Kconfig.debug +2 more+104 -01 replyApplied
3/4rtnetlink: Add assertion helpers for per-netns RTNL.include/linux/rtnetlink.h net/core/rtnetlink.c+53 -44 repliesApplied
4/4rtnetlink: Add ASSERT_RTNL_NET() placeholder for netdev notifier.net/core/Makefile net/core/rtnl_net_debug.c+132 -00 repliesApplied

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchEric Dumazet
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 net-next 0/4] rtnetlink: Per-netns RTNL.

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/[email protected]/
* Add revert of 464eb03c4a7c
* Fix Kconfig dependency for arch with no lockdep support

v1: https://lore.kernel.org/netdev/[email protected]/

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
Signature · 1 line
2.30.2