[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9b8c306a-eea0-3d77-c4a3-3406e5954eaa@nvidia.com>
Date: Sat, 4 Dec 2021 12:15:19 +0200
From: Nikolay Aleksandrov <nikolay@...dia.com>
To: Lahav Schlesinger <lschlesinger@...venets.com>,
netdev@...r.kernel.org
Cc: kuba@...nel.org, dsahern@...il.com
Subject: Re: [PATCH net-next v4] rtnetlink: Support fine-grained netdevice
bulk deletion
On 02/12/2021 19:45, Lahav Schlesinger wrote:
> Under large scale, some routers are required to support tens of thousands
> of devices at once, both physical and virtual (e.g. loopbacks, tunnels,
> vrfs, etc).
> At times such routers are required to delete massive amounts of devices
> at once, such as when a factory reset is performed on the router (causing
> a deletion of all devices), or when a configuration is restored after an
> upgrade, or as a request from an operator.
>
> Currently there are 2 means of deleting devices using Netlink:
> 1. Deleting a single device (either by ifindex using ifinfomsg::ifi_index,
> or by name using IFLA_IFNAME)
> 2. Delete all device that belong to a group (using IFLA_GROUP)
>
> Deletion of devices one-by-one has poor performance on large scale of
> devices compared to "group deletion":
> After all device are handled, netdev_run_todo() is called which
> calls rcu_barrier() to finish any outstanding RCU callbacks that were
> registered during the deletion of the device, then wait until the
> refcount of all the devices is 0, then perform final cleanups.
>
> However, calling rcu_barrier() is a very costly operation, each call
> taking in the order of 10s of milliseconds.
>
> When deleting a large number of device one-by-one, rcu_barrier()
> will be called for each device being deleted.
> As an example, following benchmark deletes 10K loopback devices,
> all of which are UP and with only IPv6 LLA being configured:
>
> 1. Deleting one-by-one using 1 thread : 243 seconds
> 2. Deleting one-by-one using 10 thread: 70 seconds
> 3. Deleting one-by-one using 50 thread: 54 seconds
> 4. Deleting all using "group deletion": 30 seconds
>
> Note that even though the deletion logic takes place under the rtnl
> lock, since the call to rcu_barrier() is outside the lock we gain
> some improvements.
>
> But, while "group deletion" is the fastest, it is not suited for
> deleting large number of arbitrary devices which are unknown a head of
> time. Furthermore, moving large number of devices to a group is also a
> costly operation.
>
> This patch adds support for passing an arbitrary list of ifindex of
> devices to delete with a new IFLA_IFINDEX attribute. A single message
> may contain multiple instances of this attribute).
> This gives a more fine-grained control over which devices to delete,
> while still resulting in rcu_barrier() being called only once.
> Indeed, the timings of using this new API to delete 10K devices is
> the same as using the existing "group" deletion.
>
> Signed-off-by: Lahav Schlesinger <lschlesinger@...venets.com>
> ---
> v3 -> v4
> - Change single IFLA_INDEX_LIST into multiple IFLA_IFINDEX
> - Fail if passing both IFLA_GROUP and at least one IFLA_IFNEX
>
> v2 -> v3
> - Rename 'ifindex_list' to 'ifindices', and pass it as int*
> - Clamp 'ops' variable in second loop.
>
> v1 -> v2
> - Unset 'len' of IFLA_IFINDEX_LIST in policy.
> - Use __dev_get_by_index() instead of n^2 loop.
> - Return -ENODEV if any ifindex is not present.
> - Saved devices in an array.
> - Fix formatting.
>
> include/uapi/linux/if_link.h | 1 +
> net/core/rtnetlink.c | 68 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 69 insertions(+)
>
I like the idea, but what happens if the same device is present twice or more times?
I mean are you sure it is safe to call dellink method of all device types multiple
times with the same device?
Cheers,
Nik
Powered by blists - more mailing lists