Skip to content

net: Speedup netdevice unregisters

Eric Dumazet netdev 1 version Applied

Status from this message: I've applied Patrick's patch, thanks everyone.

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 13 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/6net: Introduce unregister_netdevice_queue()include/linux/netdevice.h net/core/dev.c+21 -80 replies
2/6net: Introduce unregister_netdevice_many()include/linux/netdevice.h net/core/dev.c+66 -322 replies
3/6net: add a list_head parameter to dellink() methoddrivers/net/macvlan.c drivers/net/veth.c include/net/rtnetlink.h +4 more+19 -180 replies
4/6vlan: Optimize multiple unregistrationinclude/linux/if_vlan.h net/8021q/vlan.c net/core/dev.c+35 -1610 replies
5/6ipip: Optimize multiple unregistrationnet/ipv4/ipip.c+11 -60 replies
6/6gre: Optimize multiple unregistrationnet/ipv4/ip_gre.c+10 -50 replies

Reviews trailers per patch

1 of 6 patches has a Reviewed-by or Acked-by.

PatchEric Dumazet
1/6
2/6
3/6
4/6A-b
5/6
6/6

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

Read the v1 thread

Cover letter [net-next-2.6 PATCH 0/6] net: Speedup netdevice unregisters

netdevice unregisters are serialized and call synchronize_{net|rcu}() three times per device.

This means it can take a long time to remove a device, if many virtual devices are attached. (vlan, macvlan, tunnels, ...)

This patch series partially solve the problem by batching several devices in a list, so that two synchronize_net() calls can be factorized.

Some results on my dev machine (2x4 cpus, HZ=1000, PREEMPT):

modprobe dummy numdummies=10000

# unregister 10000 DOWN netdevices
time rmmod dummy

Before patches :

real    2m0.303s  (12 ms per device)
user    0m0.001s
sys     0m0.117s

After patches 1,2,3 :

real 0m1.111s
user 0m0.001s
sys 0m0.922s (mostly sysfs overhead)

modprobe dummy
ip link set dummy0 up
for f in seq 1 1000
do
ip link add link dummy0 dummy0.$f type vlan id $f ip link set dummy0.$f up
done
# Dismantle of 1000 UP vlans (but no IP address) time rmmod dummy

Before patches :

real    0m40.410s  (40 ms per vlan)
user    0m0.000s
sys     0m0.022s

After patches 1,2,3 :

real 0m20.990s
user 0m0.001s
sys 0m0.011s

After patch 4 (vlan: Use unregister_netdevice_many())

real 0m4.392s (-> 4.3 ms per vlan)
user 0m0.000s
sys 0m0.067s

We still have a synchronize_rcu() in dev_deactivate() that could be factorized in followup patches if there is some interest.

PATCH 1/6 : net: Introduce unregister_netdevice_queue() PATCH 2/6 : net: Introduce unregister_netdevice_many() PATCH 3/6 : net: Add a list_head parameter to dellink() method PATCH 4/6 : vlan: Optimize multiple unregistration PATCH 5/6 : ipip: Optimize multiple unregistration PATCH 6/6 : gre: Optimize multiple unregistration