Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3618743pxb; Mon, 24 Jan 2022 13:38:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/mKIvYqBjVcvxu6SEvI6JsRD6sILz6S7GlO43UP7kk2jz5nzMLXsKoznmvWcqVM4CnaM7 X-Received: by 2002:a17:902:b116:b0:14a:a4a1:e7a4 with SMTP id q22-20020a170902b11600b0014aa4a1e7a4mr15530639plr.82.1643060333811; Mon, 24 Jan 2022 13:38:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060333; cv=none; d=google.com; s=arc-20160816; b=v0CxspczSbuWL1XAbsFrl6OnZrSabuM/Xb+Vf8tS9j4QbfwENNptSHOjgbd0ewTiMf pJN5vwxF6Up8BtQnFLiBiA+ZQH8IhqqokSx46xbqpMumAsLRjUFU6YRem1lT2ojCcYAQ BcnFlgYrdITDfPFdrEo1wTCuDhEH189g9NTP0jWCbWogWpLFYm0dlzUA7YDnf86VAnqC VlPrVlRwZBDMFkQhaxPXrf6f9vZrowFOgnXfLESAXc3Tic+ujxtmnuZiDicW63gCRmQh iLjiL7/6qsJnQcTWiqZlgAmTEsnaQOSo5d7GtL54tmbNY21+su0J/LgDjJqHgxs2V6Ng 54Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=EsGtbwMEUdqb9IpKr0zHd0Y9bnCs9QV+drH0HQ+R1AA=; b=rV7HLzEqSUBfGmRyeujdO+nqNcJNBJVcVtxcYuG/+Db7f3fgORLlBLyxqVLpd+/55G Ruee7vAmrutWgNVEciikku/WGNi3RDNQfW9YugkBOFIqVA1h0suFv24O+Sq00BMYDEDj j3mOTRLEIamxPfI6dtkHuFL06FUu0PAWwRobucBqrmJSPcOgH/D1kXh1zorhtZSPFsOE BjOER/ZnOrNavTBqb74/Bb0t6kXILIOHJgu/b+dvb8Zz1jYsGxOiVRIKGg/YdngJiy8V DQZ51tsD965f7fj7agqeHDi/k/NuADeswJXTQEtsvFVGoIsRGSJTaNZW6Qkui5w4nKQy xmsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x17V3IUP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j10si8052482plx.255.2022.01.24.13.38.41; Mon, 24 Jan 2022 13:38:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x17V3IUP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352020AbiAXVS5 (ORCPT + 99 others); Mon, 24 Jan 2022 16:18:57 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:44026 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392091AbiAXUu0 (ORCPT ); Mon, 24 Jan 2022 15:50:26 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EE86960B1A; Mon, 24 Jan 2022 20:50:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0ABBC340E5; Mon, 24 Jan 2022 20:50:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057425; bh=q67Yuv2lFh5A7efPX2bOzffmmlUvGKImDLhXNGY13OQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x17V3IUP4VZYAcaTuXmsM+HMdPzUr9yXCZAPbfDR2wBnd7QZbIr/Hr8+g7LKaGRJ8 hNDANS41acXLU4U2Zx7QjuNosvDKE7p4ZhVBIuCDTXBA19+0WHRqGhzefheBbf4QWz w/wdGaADpcxnC3759Bdh4gYi5whjO5UvYz4G79tM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "Eric W. Biederman" , "David S. Miller" Subject: [PATCH 5.15 808/846] netns: add schedule point in ops_exit_list() Date: Mon, 24 Jan 2022 19:45:25 +0100 Message-Id: <20220124184128.801450579@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet 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 Cc: Eric W. Biederman Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- 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);