Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1205841rwb; Fri, 18 Nov 2022 14:34:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6C4NM+Z2Z1GcQdDcmb2huiMc4QHxmUoGtU0d471I44ZwWngOVaRknRf6ik/5uzI9TGFxsC X-Received: by 2002:a17:902:c103:b0:186:7006:9a5f with SMTP id 3-20020a170902c10300b0018670069a5fmr1515512pli.117.1668810870764; Fri, 18 Nov 2022 14:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668810870; cv=none; d=google.com; s=arc-20160816; b=a9b/tLnyYYo6BC82cRYEXYNwXOvTUTrMKW5u9Gmc7hCL0z0IGuf8sPW7ZYUg/9LSm3 I4a2bmukcNK6azCCB5S7/zABlHC3L+96CFdxbU6M3kwiW9ctzPMXwZrWvbVsN/ZO2F/M HTR6Cd6eGYGkGHh2/thhemb/Q09mO3/TPvFtOTYwSWg22LZsRbXleh7mrZ8phR0ZCrmz 5/W3jHcon4cbOBKhgjZtb0FiYbs/YXyrYye+Y7kO5+Jj7snrGTVlQRku+AYr8yDdLzGa DgvClhRYpujIwm8xPDciVZfWEB3rWdhRLbpz8c3X7Yc8MBnFWgrHc2T0IABM+sR/4Yby c7ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=/lKHnydpHIghN/6JsKrX2ITzMFuVPqFz2lJZo05wil0=; b=OuPvu4CsXHTKt3pLs4BuztqilvPpAenqsVOMo/4ysAx7fGgk4gHfhzVfwTN625U6fx iRwiHhjBDjPEjO0MbVfuG3zW+QDNEwvtWm/RiZ0v0650k6LZjXk/jFRB6oF8RJjnRhQ1 PiA/7nx50hrs9g6brCYqd83ffjMndYCa7llVew1aYSd2y8Rfy+yA1RDzpPQonMRvNzrU aLxJ1HXiS+vPOvHbuorBpTzxLMGhpXfZPN3boqowySMgnkaEDaafKZzwD0n/l8FvcpEz lRP5clq1pigND07AyS34qwOTBvMxJLk1vWp2/KEMmEhcFaOpNPqvPmqyaZpLzvf7z3ld 8bgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="gp2/kZJp"; 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 z7-20020a1709028f8700b0017f908814c6si4306503plo.532.2022.11.18.14.34.08; Fri, 18 Nov 2022 14:34:30 -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="gp2/kZJp"; 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 S231790AbiKRWX3 (ORCPT + 91 others); Fri, 18 Nov 2022 17:23:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231771AbiKRWXC (ORCPT ); Fri, 18 Nov 2022 17:23:02 -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 B8000B483B; Fri, 18 Nov 2022 14:22:35 -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 573EC627AB; Fri, 18 Nov 2022 22:22:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A99D0C433D7; Fri, 18 Nov 2022 22:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668810154; bh=a3Nl+YrArqrTu2MTpdS0izGKQlH4Fq++iKt1qyZa3+Y=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=gp2/kZJpsVukVoT67G8faL/czaxkOfRGsVmGCzE0ikD3icNUwtJER8U7RaZEIQhHN 2I+caJbL8GbpnMvvwYZI49bu4DdPoW9zj3VsSaSUv7f9ar5OAbBg/uungjiqUSYNpa wlkrnW6AxwPZ2mRjtv0ovM/YWM7w4LC67KB7vdifNuArXjR85kbcaWabe5DLz903Jz OHYqxkmHJRnxlnB7Vu4+wv6nHorbDGro/580kZF3atWQ3jwsSdwFetkiK+xp0N+hWR 7T4zNAFoGdvkjeepfvMUwgbOMB654sfGBy0Sy/jVhrzd7o6QZaXlGwevBmMHbO8Mkq g876Gu9uKtMeQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 4BD435C0F9C; Fri, 18 Nov 2022 14:22:34 -0800 (PST) Date: Fri, 18 Nov 2022 14:22:34 -0800 From: "Paul E. McKenney" To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, David Ahern , "David S. Miller" , Eric Dumazet , Hideaki YOSHIFUJI , Jakub Kicinski , netdev@vger.kernel.org, Paolo Abeni , rcu@vger.kernel.org, rostedt@goodmis.org, fweisbec@gmail.com Subject: Re: [PATCH v2 1/2] net: Use call_rcu_flush() for dst_destroy_rcu Message-ID: <20221118222234.GP4001@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20221118191909.1756624-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221118191909.1756624-1-joel@joelfernandes.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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 > > 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) Queued and pushed, wordsmithed as shown below, thank you! Thanx, Paul ------------------------------------------------------------------------ commit dee2cd7a0d6f3274bdcfe902cf7914b9553355b3 Author: Joel Fernandes (Google) 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 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) 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 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);