Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3571039pxb; Mon, 24 Jan 2022 12:29:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzjQuLNdaxF6/3rh2iDbNw5qZ3FqCW47rI9PSY/QuWzzOFuvuA/zCUdKY7B4MYJHdNhjlE5 X-Received: by 2002:a17:90b:1a87:: with SMTP id ng7mr36170pjb.233.1643056187606; Mon, 24 Jan 2022 12:29:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056187; cv=none; d=google.com; s=arc-20160816; b=j/RHwt8Ez4s3r5QtDa5wDeCHt7d5QlseOq7J83lNUhTBvuiEG5voluvHmFTPBpA+JI RYsOeM3plFKJv+04kEsOtLzhObxYoytow4Z+7xQjwwDTOy3jD+dpCGqayCHpjv45RMPS aUnx5iSpGNzp/9jTvsCxQASvZf/6ACFfjSC0/wT1tS4OKHE5d2TBfkswXGcZaLrw1paf vHIixaMlx32bUX+RD2ij6O0/8Dk54Nz11HZM8dk0jPFyk27oKwFeOeYdjVAnLKxXV1E1 30GrTCCRCeqc/bMTDhoeHBiEpwySUOBihwK0IKOHyRWEbe6OQy+56LTr7t8Nme31+ISn Y2cA== 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=BBbysSILjD9DYLGHWAH4rBccMqds5uC9GFwKxr0trV4=; b=CbmRoibW9jLdL0eO2HcPhLWl+g9Xgvoygztp+kAt2zC1ARFF+uP+u0kVgG11FhFvuC zcfoahMP0F3ZiccK+Z8vOCe0GculZK5/mqm882NpYYHcy6eSV34ea6U3DOt1dxrntl3g ixIWFCePr8PWaCYT2kNVI2FhPCzGhS0umu3uDVLXTmbuvCGjQycst/ivFAkLj5xwE7AX Am5q0xws0bbE3SPIllXiwYmEqniPQsHpEClELlAw9qpsQW1clGwPEBE03MKah7AVcErq N4qQ34DIpy0nd5Q6vjpT8QyTRspibORZFGhs17fdvYQmP5JcMBrMgv/KZ5ZM0/exQhkZ mZnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pXtjxPc2; 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 c22si14203041pls.503.2022.01.24.12.29.35; Mon, 24 Jan 2022 12:29:47 -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=pXtjxPc2; 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 S1353080AbiAXTck (ORCPT + 99 others); Mon, 24 Jan 2022 14:32:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348030AbiAXTXZ (ORCPT ); Mon, 24 Jan 2022 14:23:25 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5BD7C06125B; Mon, 24 Jan 2022 11:11:04 -0800 (PST) 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 86C3460909; Mon, 24 Jan 2022 19:11:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41EF1C340E5; Mon, 24 Jan 2022 19:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051464; bh=mDquujr8OPPM9a1khBGrB/a/+a3dDoDKnUi8nbhr/iA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pXtjxPc2g47ApNpC7wJeR6hMQ/zW19Rp6XaJ9+0/YRomuIA+2a/6hxCVazNl7qfAY Lqao7v6MgQTHIXFau9DijvFXiclHVgZEdb57sh40iMTSOuOlHUp3uQ0BN1EDRadHfi 1sz0NZXUU4ACjhHZ/aK7TxCL8tpeQZFVWyQRmBCw= 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 4.14 170/186] netns: add schedule point in ops_exit_list() Date: Mon, 24 Jan 2022 19:44:05 +0100 Message-Id: <20220124183942.584678820@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 @@ -138,8 +138,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);