Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3577072pxb; Mon, 24 Jan 2022 12:38:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQttDehgdtgBBPY0geCdE20wBG1WqW8e0lh/8mpZRvZRgbHkGEWGsqQghDsvCcvF5PaUCc X-Received: by 2002:a05:6a00:9a9:b0:4c1:c43e:75e4 with SMTP id u41-20020a056a0009a900b004c1c43e75e4mr15195605pfg.83.1643056710663; Mon, 24 Jan 2022 12:38:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056710; cv=none; d=google.com; s=arc-20160816; b=MM4Xf3P7f+mxEKesLpmt3PdFAsMWhT1BHQ5s5dlSBkAfOz5+ite/ou269cpHmgAy1m N9i76PdzDE5syayV+0ZA+57pRWOE/fr0wFUfx3B0qVsdTVvlFGGjPYSZXbw8OyI74cMU KNpqmeQNxSgqA28DuzeZuNZjDaEYEFbvEugDCAH5pRdCQ+D1T2pzLLk582I2j91N03WF J1HEgo0Z2GZZu89GwTnwG/PVbltk+gjYu0CSSW94Mlx4K97l3uS8hfX+QOkMIdhUm46q cdbyQGY/G1kUO9KGFngVnndkCYKLRDVcLCpHAqOtzelZEM+rc+mDnzPYtnl915HRMT4V VS+Q== 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=RaxoP9o/ndBpFpCwERD58cdu7mPM3xptjdgd8D942sI=; b=QNR07QUHAn2EitwHriBP+d/zIvX351jqTbWLX2llVNB56Gv2dXf1Y5q6cG0l5qcDxs jfCWrtJbpKBDuGS6a0ZJIOKqf0wiNcnWVmeq5K3Enu+epEIKM2CspaYYPLAgSCs0sDXt m9qXT4y9iDAzF85CSyUTwAh6SWc0OClffvgIVyOPIEHOD+cqwrLFF74/t41KJRddRQRa 7gO9HHx4Rpt5P6gFUMe/K8LlM9IBmM+5sIJXoHx4ldz3ZrB0RVlY8Ap3EXaXIuFYzzT7 6jMv7afLBkfrD+H8Y+2awMTm1WfupfkfuyiQ/C6/GNAaCOhvPQsfRZNsT/19NXhnyggS Px8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DgnYED6R; 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 z184si14506615pgz.213.2022.01.24.12.38.11; Mon, 24 Jan 2022 12:38:30 -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=DgnYED6R; 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 S1357460AbiAXTuD (ORCPT + 99 others); Mon, 24 Jan 2022 14:50:03 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:60068 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354921AbiAXTji (ORCPT ); Mon, 24 Jan 2022 14:39:38 -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 ams.source.kernel.org (Postfix) with ESMTPS id D219CB810BD; Mon, 24 Jan 2022 19:39:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0811C340E5; Mon, 24 Jan 2022 19:39:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053174; bh=5vvXEwtT+nl1XZYj/msZ/ibkaZkOY9t/AmP0MCYpxQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DgnYED6RraJNO101Mb6Hi51wdYyQCkjjb0gOMKtxSq8q6ZUrlEU56QEUHjX8tH+i9 pRywiHqX+O/stuY5BBbes5R+Kn9ikI+Iz3rIrJnE6kiiPTiRS5CavueT9wHJyVG6Ef Q5HCuGuVXgsraQZpP0U5W6JyHvDW5cpcGT35G4uc= 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.4 300/320] netns: add schedule point in ops_exit_list() Date: Mon, 24 Jan 2022 19:44:44 +0100 Message-Id: <20220124184004.156321648@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 @@ -168,8 +168,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);