Skip to content

net: speedup netns dismantles

Eric Dumazet netdev 2 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest11 patches 1 replyApplied 11/11
  2. v111 patches 14 repliesSuperseded

Patches in v2 All 11 applied

#Subject and filesSizeRepliesApplied
1/11ipv6/addrconf: allocate a per netns hash tableinclude/net/netns/ipv6.h net/ipv6/addrconf.c+24 -00 repliesApplied
2/11ipv6/addrconf: use one delayed work per netnsinclude/net/netns/ipv6.h net/ipv6/addrconf.c+25 -200 repliesApplied
3/11ipv6/addrconf: switch to per netns inet6_addr_lst hash tablenet/ipv6/addrconf.c+23 -540 repliesApplied
4/11nexthop: change nexthop_net_exit() to nexthop_net_exit_batch()net/ipv4/nexthop.c+8 -40 repliesApplied
5/11ipv4: add fib_net_exit_batch()net/ipv4/fib_frontend.c+16 -30 repliesApplied
6/11ipv6: change fib6_rules_net_exit() to batch modenet/ipv6/fib6_rules.c+8 -30 repliesApplied
7/11ip6mr: introduce ip6mr_net_exit_batch()net/ipv6/ip6mr.c+15 -50 repliesApplied
8/11ipmr: introduce ipmr_net_exit_batch()net/ipv4/ipmr.c+15 -50 repliesApplied
9/11can: gw: switch cangw_pernet_exit() to batch modenet/can/gw.c+6 -31 replyApplied
10/11bonding: switch bond_net_exit() to batch modedrivers/net/bonding/bond_main.c drivers/net/bonding/bond_procfs.c+19 -90 repliesApplied
11/11net: remove default_device_exit()net/core/dev.c+14 -80 repliesApplied

Reviews trailers per patch

10 of 11 patches have a Reviewed-by or Acked-by.

PatchDavid AhernOliver HartkoppMarc Kleine-Budde
1/11R-b
2/11R-b
3/11R-b
4/11R-b
5/11R-b
6/11R-b
7/11R-b
8/11R-b
9/11A-b A-b
10/11
11/11R-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 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 net-next 00/11] net: speedup netns dismantles

From: Eric Dumazet <[email protected]>

In this series, I made network namespace deletions more scalable, by 4x on the little benchmark described in this cover letter.

- Remove bottleneck on ipv6 addrconf, by replacing a global hash table to a per netns one.

- Rework many (struct pernet_operations)->exit() handlers to exit_batch() ones. This removes many rtnl acquisitions, and gives to cleanup_net() kind of a priority over rtnl ownership.

Tested on a host with 24 cpus (48 HT)

Test script:

for nr in {1..10}
do
(for i in {1..10000}; do unshare -n /bin/bash -c "ifconfig lo up"; done) &
done
wait

for i in {1..10}
do
sleep 1
echo 3 >/proc/sys/vm/drop_caches
grep net_namespace /proc/slabinfo
done

Before: We can see host struggles to clean the netns, even after there are no new creations. Memory cost is high, because each netns consumes a good amount of memory.

time ./unshare10.sh

net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      82634  82634   3968    1    1 : tunables   24   12    8 : slabdata  82634  82634      0
net_namespace      37214  37792   3968    1    1 : tunables   24   12    8 : slabdata  37214  37792    192

real 6m57.766s
user 3m37.277s
sys 40m4.826s

After: We can see the script completes much faster, the kernel thread doing the cleanup_net() keeps up just fine. Memory cost is not too big.

time ./unshare10.sh

net_namespace       9945   9945   4096    1    1 : tunables   24   12    8 : slabdata   9945   9945      0
net_namespace       4087   4665   4096    1    1 : tunables   24   12    8 : slabdata   4087   4665    192
net_namespace       4082   4607   4096    1    1 : tunables   24   12    8 : slabdata   4082   4607    192
net_namespace        234    761   4096    1    1 : tunables   24   12    8 : slabdata    234    761    192
net_namespace        224    751   4096    1    1 : tunables   24   12    8 : slabdata    224    751    192
net_namespace        218    745   4096    1    1 : tunables   24   12    8 : slabdata    218    745    192
net_namespace        193    667   4096    1    1 : tunables   24   12    8 : slabdata    193    667    172
net_namespace        167    609   4096    1    1 : tunables   24   12    8 : slabdata    167    609    152
net_namespace        167    609   4096    1    1 : tunables   24   12    8 : slabdata    167    609    152
net_namespace        157    609   4096    1    1 : tunables   24   12    8 : slabdata    157    609    152

real 1m43.876s
user 3m39.728s
sys 7m36.342s

v2: - fix a typo on ASSER_RTNL() (kernel build bots)
- add reviewers approvals.

Eric Dumazet (11):
ipv6/addrconf: allocate a per netns hash table ipv6/addrconf: use one delayed work per netns ipv6/addrconf: switch to per netns inet6_addr_lst hash table
nexthop: change nexthop_net_exit() to nexthop_net_exit_batch()
ipv4: add fib_net_exit_batch()
ipv6: change fib6_rules_net_exit() to batch mode
ip6mr: introduce ip6mr_net_exit_batch()
ipmr: introduce ipmr_net_exit_batch()
can: gw: switch cangw_pernet_exit() to batch mode
bonding: switch bond_net_exit() to batch mode
net: remove default_device_exit()

 drivers/net/bonding/bond_main.c   |  27 ++++--
 drivers/net/bonding/bond_procfs.c |   1 -
 include/net/netns/ipv6.h          |   5 ++
 net/can/gw.c                      |   9 +-
 net/core/dev.c                    |  22 +++--
 net/ipv4/fib_frontend.c           |  19 +++-
 net/ipv4/ipmr.c                   |  20 +++--
 net/ipv4/nexthop.c                |  12 ++-
 net/ipv6/addrconf.c               | 139 ++++++++++++++----------------
 net/ipv6/fib6_rules.c             |  11 ++-
 net/ipv6/ip6mr.c                  |  20 +++--
 11 files changed, 172 insertions(+), 113 deletions(-)
Signature · 1 line
2.35.0.263.gb82422642f-goog