Message ID | 20221118191909.1756624-1-joel@joelfernandes.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp371277wrr; Fri, 18 Nov 2022 11:29:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf5sK8tGnOL5I6bz7kZWudZhEXf+kOxy4uI3NSfszpMtKd0c5Mfez8iTEhxz5qkLL8iz9mbO X-Received: by 2002:a17:902:cf05:b0:188:53bd:878a with SMTP id i5-20020a170902cf0500b0018853bd878amr1055910plg.12.1668799779135; Fri, 18 Nov 2022 11:29:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668799779; cv=none; d=google.com; s=arc-20160816; b=LBcsfe9YLXvwrsISROgrJrooNOT95fHkK8H9h58r+IzwkUsqansvmZvzudC/JXwv00 J681sGkDpYdBqv8ATewi3eeuMTIkH/vBrSfUIBoGMK1wzjaJaVFMZzg8GY0nGHS/0Pv3 VfplHnDrjdUEvZSVMZPL3qXjySx2fn6zta/VB0x+o3/MBcJs13PaBZ0DuFgNhKFOia+0 U9fSiWPljUUzYWg8UEJ30E/JNX+PHbmi07IGqxbvBUfkv7AGdPceRZYvUXcfwCnzECJp og6XfBy86D5hAgndeUsKEdURCip4KZm9qEa0PBN0qH/ZsSxIPHo7En7Pt1KzcYvb8mku wBFQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8hJIDHLBXF0giuH5POYZYhMSuPEuGT60Uc/uAs3zlWI=; b=cOjUpoPQ9EUWvtmnD4sYKt+HWfZzeeFqhWvAkuIO+nEN//iGwU8cc6ALgkWmJvpj1u aHrCD+XYcKA3xvSYduFrY7or5l8vfq9IIy4kx1seQzcIlaKcqBKp3PM88UH1VWKWtNju h0qcrRhTeNCfPfQWCz5nK2ksJkAwqJfurEhMIvFJCRDb+B+RK31tcUGjQHGwmThMf520 /C48kPGFa3Qe4ry+j+oinASGFBE6Kh8+RgdpH1C0zY6mhxbOa51irESNiQ/RdZ2B+6B1 W+6mGJE2IU0iGgD3SEFQX/lnDnN13G/ZAb5RWP9CXPYXjYEBALAGQR1oH5YmdAWxCQhc neCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=pshyycCa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020a631c43000000b004470e9c2e53si4589751pgm.591.2022.11.18.11.29.26; Fri, 18 Nov 2022 11:29:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=pshyycCa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242190AbiKRTTc (ORCPT <rfc822;kkmonlee@gmail.com> + 99 others); Fri, 18 Nov 2022 14:19:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235527AbiKRTT3 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 18 Nov 2022 14:19:29 -0500 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9E0A6457D for <linux-kernel@vger.kernel.org>; Fri, 18 Nov 2022 11:19:26 -0800 (PST) Received: by mail-qk1-x735.google.com with SMTP id k4so4111329qkj.8 for <linux-kernel@vger.kernel.org>; Fri, 18 Nov 2022 11:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8hJIDHLBXF0giuH5POYZYhMSuPEuGT60Uc/uAs3zlWI=; b=pshyycCa9K3066tR7yK8eyCk/6IKgxQcw8JtBoKV/FxCYuUPhkZia4zqJr7ZOQsnsH tiHH4G51c7+2xyWLJOSzUt5s5IsgPwglvg2P5o60nmoZWQeCT0XL6DeQBCZVQH9VAf/R hk3ORJwKdt+yY2896qFj/fpXzjZYA2dmIyPjc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8hJIDHLBXF0giuH5POYZYhMSuPEuGT60Uc/uAs3zlWI=; b=lF0Jx+qQhVaaUNR9ROEkCVOaStUjqMXsIzQ5Msg+i7zrcvXEaezm78zrRfkHnPTm/E IMrFXFTdZm+jqDev5o2rVwn3HrvQ5h+CwvLVS29WlP4SifKEJ/fsWU3WKxotAaOBU9sO xPvleGzDdwfsKdN8MqJSaJh6oXlmOyXvq5paaZGFY6TYbh5NigJtpg6NC7/Z2eQEd8aM PuCi9mWe02IkJL17Z8HAWGOJnfzDFwz9NuVSvILCL8VA7pWLWn/zqBtyreKeWs9WNG76 pr3IQmLn+p9ZSKNMmQXPyZhh5Foik0U3M70Vj+hH6CU/uXhVFFgNG6twLTRuZI0qHfHU yXpw== X-Gm-Message-State: ANoB5pnsePGs39oTxgNSn73SwvwcnndD6fhWSckBmhHbDc3e3W+XBAUj 9HDRigdJlGQnMRx8G73d7MJdLAL7XBn4FQ== X-Received: by 2002:ae9:e50d:0:b0:6f9:f247:88ca with SMTP id w13-20020ae9e50d000000b006f9f24788camr7209922qkf.59.1668799165793; Fri, 18 Nov 2022 11:19:25 -0800 (PST) Received: from joelboxx.c.googlers.com.com (228.221.150.34.bc.googleusercontent.com. [34.150.221.228]) by smtp.gmail.com with ESMTPSA id w9-20020a05620a424900b006ce2c3c48ebsm2958122qko.77.2022.11.18.11.19.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 11:19:25 -0800 (PST) From: "Joel Fernandes (Google)" <joel@joelfernandes.org> To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>, David Ahern <dsahern@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>, Jakub Kicinski <kuba@kernel.org>, netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>, rcu@vger.kernel.org, rostedt@goodmis.org, paulmck@kernel.org, fweisbec@gmail.com Subject: [PATCH v2 1/2] net: Use call_rcu_flush() for dst_destroy_rcu Date: Fri, 18 Nov 2022 19:19:08 +0000 Message-Id: <20221118191909.1756624-1-joel@joelfernandes.org> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749863397210433713?= X-GMAIL-MSGID: =?utf-8?q?1749863397210433713?= |
Series |
[v2,1/2] net: Use call_rcu_flush() for dst_destroy_rcu
|
|
Commit Message
Joel Fernandes
Nov. 18, 2022, 7:19 p.m. UTC
In a networking test on ChromeOS, we find that using the new
CONFIG_RCU_LAZY causes a networking test to fail in the teardown phase.
The failure happens during: ip netns del <name>
Using ftrace, I found the callbacks it was queuing which this series fixes.
Use call_rcu_flush() to revert to the old behavior. With that, the test
passes.
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
net/core/dst.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, Nov 18, 2022 at 07:19:08PM +0000, Joel Fernandes (Google) wrote: > In a networking test on ChromeOS, we find that using the new > CONFIG_RCU_LAZY causes a networking test to fail in the teardown phase. > > The failure happens during: ip netns del <name> > > Using ftrace, I found the callbacks it was queuing which this series fixes. > Use call_rcu_flush() to revert to the old behavior. With that, the test > passes. > > Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> Queued and pushed, wordsmithed as shown below, thank you! Thanx, Paul ------------------------------------------------------------------------ commit dee2cd7a0d6f3274bdcfe902cf7914b9553355b3 Author: Joel Fernandes (Google) <joel@joelfernandes.org> Date: Fri Nov 18 19:19:08 2022 +0000 net: Use call_rcu_flush() for dst_release() In a networking test on ChromeOS, kernels built with the new CONFIG_RCU_LAZY=y Kconfig option fail a networking test in the teardown phase. This failure may be reproduced as follows: ip netns del <name> The CONFIG_RCU_LAZY=y Kconfig option was introduced by earlier commits in this series for the benefit of certain battery-powered systems. This Kconfig option causes call_rcu() to delay its callbacks in order to batch them. This means that a given RCU grace period covers more callbacks, thus reducing the number of grace periods, in turn reducing the amount of energy consumed, which increases battery lifetime which can be a very good thing. This is not a subtle effect: In some important use cases, the battery lifetime is increased by more than 10%. This CONFIG_RCU_LAZY=y option is available only for CPUs that offload callbacks, for example, CPUs mentioned in the rcu_nocbs kernel boot parameter passed to kernels built with CONFIG_RCU_NOCB_CPU=y. Delaying callbacks is normally not a problem because most callbacks do nothing but free memory. If the system is short on memory, a shrinker will kick all currently queued lazy callbacks out of their laziness, thus freeing their memory in short order. Similarly, the rcu_barrier() function, which blocks until all currently queued callbacks are invoked, will also kick lazy callbacks, thus enabling rcu_barrier() to complete in a timely manner. However, there are some cases where laziness is not a good option. For example, synchronize_rcu() invokes call_rcu(), and blocks until the newly queued callback is invoked. It would not be a good for synchronize_rcu() to block for ten seconds, even on an idle system. Therefore, synchronize_rcu() invokes call_rcu_flush() instead of call_rcu(). The arrival of a non-lazy call_rcu_flush() callback on a given CPU kicks any lazy callbacks that might be already queued on that CPU. After all, if there is going to be a grace period, all callbacks might as well get full benefit from it. Yes, this could be done the other way around by creating a call_rcu_lazy(), but earlier experience with this approach and feedback at the 2022 Linux Plumbers Conference shifted the approach to call_rcu() being lazy with call_rcu_flush() for the few places where laziness is inappropriate. Returning to the test failure, use of ftrace showed that this failure cause caused by the aadded delays due to this new lazy behavior of call_rcu() in kernels built with CONFIG_RCU_LAZY=y. Therefore, make dst_release() use call_rcu_flush() in order to revert to the old test-failure-free behavior. Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org> Cc: David Ahern <dsahern@kernel.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: <netdev@vger.kernel.org> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> diff --git a/net/core/dst.c b/net/core/dst.c index bc9c9be4e0801..15b16322703f4 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -174,7 +174,7 @@ void dst_release(struct dst_entry *dst) net_warn_ratelimited("%s: dst:%p refcnt:%d\n", __func__, dst, newrefcnt); if (!newrefcnt) - call_rcu(&dst->rcu_head, dst_destroy_rcu); + call_rcu_flush(&dst->rcu_head, dst_destroy_rcu); } } EXPORT_SYMBOL(dst_release);
diff --git a/net/core/dst.c b/net/core/dst.c index bc9c9be4e080..15b16322703f 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -174,7 +174,7 @@ void dst_release(struct dst_entry *dst) net_warn_ratelimited("%s: dst:%p refcnt:%d\n", __func__, dst, newrefcnt); if (!newrefcnt) - call_rcu(&dst->rcu_head, dst_destroy_rcu); + call_rcu_flush(&dst->rcu_head, dst_destroy_rcu); } } EXPORT_SYMBOL(dst_release);