Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2796003rwb; Wed, 30 Nov 2022 10:59:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4kNoDJexyUz75BEvswOYmdpzo2PJmnJzscV5FTYu6h0okRLpknbDY/oCMR04tOoqa8KqDB X-Received: by 2002:aa7:c759:0:b0:46a:b8e0:f73a with SMTP id c25-20020aa7c759000000b0046ab8e0f73amr25101225eds.425.1669834744083; Wed, 30 Nov 2022 10:59:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669834744; cv=none; d=google.com; s=arc-20160816; b=ol3njl9QRG0zHMimjHaNazTjcDJgfdDzxsdiPNxzgUFK4woqYgXlJ01u4LDF17K5Ax wfZUl7xwJU8ubTQ7t0BqF4R5w4gzQzNwir0xtd37u9DTIGg7znNBw7cwyziSImbB4Njn Fbd4JPKEpOHDj9BLdVYoeqbebRhF0rEwYUQwoVkTBXBaUzX1cMME5KvEEeichE3RQS6R 7qWCInEweyO4fm7HKAjx1YnmztsWlSz7IGhMKDsCAN29SFQ1OtQzRPW8MnxzW2gfrCNw +GKtTDfoG3TBwMKAIiMMAmBynB6Eh6SNVHpIHZ05yTi3b4SEMyp9hD03n17ML5ViKf2b ovUg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1zXdvyfc1MP3KLtbXijQXOY0+CV9MXBH71IhPP6Bqec=; b=yYf9h3PdCxJkPhqAumguJbAAGWskn2Nuev47VObYQNndcTrq0QW7hYmnn6RkD1ntj4 wQCBkNbehx2a4B8bWPekC8SI13zld3MsCRqnse02DtVm1j6DpUN51MpwbI36YfLBfNFg IBR531z7T6YgMuky5ODZSisK1eIsqHidARUFQ9UXMlJQe2gzqBmPP+E9D1vo3oLnspLU OmfAL2vi30UXM7IySroA33pvKh5H8fpj+2tdV+LjgTScgvAg37pTrIaQZpI9W3mtUPkL 4CmJxkggaWjdKBZd4cvFoGe0RRrJIPI/zfrZprQFAzw10hOmD0TDiEN6eeHnWC0bDQ17 oQXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Qn/G0f3u"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r12-20020aa7d14c000000b004520b01a355si1758744edo.52.2022.11.30.10.58.33; Wed, 30 Nov 2022 10:59:04 -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=@kernel.org header.s=k20201202 header.b="Qn/G0f3u"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbiK3SOk (ORCPT + 83 others); Wed, 30 Nov 2022 13:14:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbiK3SNd (ORCPT ); Wed, 30 Nov 2022 13:13:33 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D0E862E7; Wed, 30 Nov 2022 10:13:31 -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 8630DB81CA1; Wed, 30 Nov 2022 18:13:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2187AC4315A; Wed, 30 Nov 2022 18:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669832008; bh=tLEwwsXJ50F5WMjv+BokwLjrPrLGPh46UmjaqeJOMNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qn/G0f3uTFbWSF42AqjtciE1KrJdOMt55GTNskCSfXG+ehVdvjQo7PT/4uic/Xzg1 Wi/E5KetpU6444YTs4tO67fBw4KORpTJ0BKVkR/Z3EMAh6cV20/1KWN/BxoKaOaAAN 4IPkSER2QT2w1PfvXv0JlBCGSXN2yG7XA0W899GLRdiFLJ5uYDWtNbzwrVYZ5jU9iz hauOlXc4XrtNkMQU9gYEnLcdZLg3winmFw/9vpHoo+ESsEjtdGfVEVJ2RCwpQJVQq1 NwKPlMpxbYYVPJjir5RwdfEOfd2sKQckEBkPR+Stgh/QD3zHNsxWDTgBaOGCX58MaF 0ukAfUlmoFqgg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 724285C1A02; Wed, 30 Nov 2022 10:13:27 -0800 (PST) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Joel Fernandes (Google)" , David Ahern , "David S. Miller" , Eric Dumazet , Hideaki YOSHIFUJI , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, "Paul E . McKenney" Subject: [PATCH rcu 15/16] net: Use call_rcu_hurry() for dst_release() Date: Wed, 30 Nov 2022 10:13:24 -0800 Message-Id: <20221130181325.1012760-15-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20221130181316.GA1012431@paulmck-ThinkPad-P17-Gen-1> References: <20221130181316.GA1012431@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org From: "Joel Fernandes (Google)" 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 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_hurry() instead of call_rcu(). The arrival of a non-lazy call_rcu_hurry() 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_hurry() 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_hurry() in order to revert to the old test-failure-free behavior. [ paulmck: Apply s/call_rcu_flush/call_rcu_hurry/ feedback from Tejun Heo. ] Signed-off-by: Joel Fernandes (Google) Cc: David Ahern Cc: "David S. Miller" Cc: Eric Dumazet Cc: Hideaki YOSHIFUJI Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Signed-off-by: Paul E. McKenney --- net/core/dst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/dst.c b/net/core/dst.c index bc9c9be4e0801..a4e738d321ba2 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_hurry(&dst->rcu_head, dst_destroy_rcu); } } EXPORT_SYMBOL(dst_release); -- 2.31.1.189.g2e36527f23