Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3974108pxb; Tue, 25 Jan 2022 00:22:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQMqbmM0TZeLUFFq0PKapRpb0lmWLQkJz9kDGWlJ+xBzdqMkeFg9/h+KWo/Zn640MZnc4n X-Received: by 2002:a05:6402:5291:: with SMTP id en17mr19251324edb.256.1643098963033; Tue, 25 Jan 2022 00:22:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098963; cv=none; d=google.com; s=arc-20160816; b=dUUWMu3EyMDk0CD/kG1ABqOFromAPzefmlSxcj7mVmsHvhH6CNA9vE2fJ3r+AQNEIK /Vzk4Ce6B2kmTDPQV8OVhSn2CZ8I+x4rCrfdypbVJTl22m/7U7uqThOhWX89u8x9PJae OzLBJ7qWcQon47wKqaRCND82zkie7qi4MDEygnlen+LtR92Zt6XG67R0EC1X5Bz70Zqc UHycAFtBD54sqlRsM/asY5wEooZwDL5bXeyBsqmTKGWYvgyD2zryfxWNjnD0ONqGQ0K+ HxJGuztLEOlax+QoqNahACff5EiRSE8B6YUERGdYtkh2v9778mDQ5B3TRJI1zKxqS2O0 muCQ== 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=IC28MZPmuMCWTN6nQyztq5LPzpSjRna3gON+vgnU1DQ=; b=Q572xb7wsFY/s7oypj1yvu0IeXsQWFjQjm/ZsOSjwJ5U+PS3F9yJcRKAr1/HGsZetj Im3lufU/xh4Dxy4d63NdOnzkqUcMsOwR7ShQGLalVVzoSlkbUmQbsN8Cy4hO5D6Amjq1 9jDjBBbvxMrewt9pr1p/ovWgt7XwpAew6Loi38c94geLe/S/JAuxPMJWGNUWX8hwBepP 73jEPP89sjud3c90d4GgE8p+UMqMyXMCy/FBrfBxpSCQoe466kt2P2Bbua+E0Y4qdumZ kxqrIHpfYxHSkukcepXfDAkUBzTp4NrFNRer+KJzW/PQFKA62xt8lHdmHFii5faVFZa6 xYbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=j9NYMuch; 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 hr36si3937200ejc.955.2022.01.25.00.22.18; Tue, 25 Jan 2022 00:22:43 -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=j9NYMuch; 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 S3421060AbiAYC0E (ORCPT + 99 others); Mon, 24 Jan 2022 21:26:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244557AbiAXTsh (ORCPT ); Mon, 24 Jan 2022 14:48:37 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50DD3C02B8D6; Mon, 24 Jan 2022 11:23:36 -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 ams.source.kernel.org (Postfix) with ESMTPS id C60EFB810BD; Mon, 24 Jan 2022 19:23:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D666EC340E5; Mon, 24 Jan 2022 19:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052213; bh=Cxrhw0mczMyhZ1QX+B6rSfeV8iyoAeiPu4kVy1aqEBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j9NYMuchI3L3FabQl2ozMpKyWh+hWM47Ze3vf2wXBvy+FoJYilbReAXwcAF+vU8A9 WlkPAYUZnyUFMxXHjwn9YJtZyojMirPL6NKPGSVBfG5muOZgXrvDy0qh7phTfH1VLt yS0vaVChfKh2QZPh5lvzkFxDXKTXZThEmpL4RT3o= 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.19 226/239] netns: add schedule point in ops_exit_list() Date: Mon, 24 Jan 2022 19:44:24 +0100 Message-Id: <20220124183950.294608115@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@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 @@ -149,8 +149,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);