This is a note to let you know that I've just added the patch titled netns: add schedule point in ops_exit_list() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: netns-add-schedule-point-in-ops_exit_list.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 2836615aa22de55b8fca5e32fe1b27a67cda625e Mon Sep 17 00:00:00 2001 From: Eric Dumazet <edumazet@xxxxxxxxxx> Date: Tue, 18 Jan 2022 03:43:40 -0800 Subject: netns: add schedule point in ops_exit_list() From: Eric Dumazet <edumazet@xxxxxxxxxx> commit 2836615aa22de55b8fca5e32fe1b27a67cda625e upstream. When under stress, cleanup_net() can have to dismantle netns in big numbers. ops_exit_list() currently calls many helpers [1] that have no schedule point, and we can end up with soft lockups, particularly on hosts with many cpus. Even for moderate amount of netns processed by cleanup_net() this patch avoids latency spikes. [1] Some of these helpers like fib_sync_up() and fib_sync_down_dev() are very slow because net/ipv4/fib_semantics.c uses host-wide hash tables, and ifindex is used as the only input of two hash functions. ifindexes tend to be the same for all netns (lo.ifindex==1 per instance) This will be fixed in a separate patch. Fixes: 72ad937abd0a ("net: Add support for batching network namespace cleanups") Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx> Cc: Eric W. Biederman <ebiederm@xxxxxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/core/net_namespace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -164,8 +164,10 @@ static void ops_exit_list(const struct p { struct net *net; if (ops->exit) { - list_for_each_entry(net, net_exit_list, exit_list) + list_for_each_entry(net, net_exit_list, exit_list) { ops->exit(net); + cond_resched(); + } } if (ops->exit_batch) ops->exit_batch(net_exit_list); Patches currently in stable-queue which might be from edumazet@xxxxxxxxxx are queue-5.15/ipv4-avoid-quadratic-behavior-in-netns-dismantle.patch queue-5.15/af_unix-annote-lockless-accesses-to-unix_tot_inflight-gc_in_progress.patch queue-5.15/ipv4-update-fib_info_cnt-under-spinlock-protection.patch queue-5.15/net_sched-restore-mpu-xxx-handling.patch queue-5.15/netns-add-schedule-point-in-ops_exit_list.patch queue-5.15/inet-frags-annotate-races-around-fqdir-dead-and-fqdir-high_thresh.patch queue-5.15/ppp-ensure-minimum-packet-size-in-ppp_write.patch queue-5.15/xfrm-fix-a-small-bug-in-xfrm_sa_len.patch