Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3013845rwb; Wed, 30 Nov 2022 14:09:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf7g/oLl7ZF5azlZywheRrMMmSGbI5J0Y92q1pn9+0ZxCqDhEz8SjjEDThnaeAJSDPgtebYI X-Received: by 2002:a63:2306:0:b0:46f:918e:7339 with SMTP id j6-20020a632306000000b0046f918e7339mr37214980pgj.429.1669846184109; Wed, 30 Nov 2022 14:09:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669846184; cv=none; d=google.com; s=arc-20160816; b=wcsrD/YiIVnHmvrEkMv4XrxeDDY9JE7gemDEBq0L0Ma6AUDpNNIy5iWWXuS6a5bXQD +G+UtEwntxCOuBqF91gmbe5aKK48z2SSK0aWNlMaphcybU0aoplzJ+O+jYeKxG3mcP0d tx5AERlMbq1kR68uLxy7kIOexNyehD/k35gXquwfMehBawTUsTJux2b+jAibfS3kZ/NR CjlOpzgg1xTQwGNvGYcwC9JhDJBT9ZCuA7lskv0rewlvDWSVRj8X5QpI5yiLsx1BdciB RhncufASyDumvkFeRWFgcBPmLqnAH9XGO1yBKJX+dH6vewOwnFkQmfTmCFGbQVwxv5Om P5wA== 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=ACfKCAScXnaW3ztMx0XWCTA/qWNAXn/DRnFiMvVCk0E=; b=MDtbhe0z88TlACcOWOI8O2IYc0m5WqTnpq2Fr7wi/u4U6kx5v1fmfOzSN+PgFiqduH mzZGPBmVIQeJ25sqvjlbAe+O2+kZFdQeSJX2/mwBWgrEyeWYC7Z/AdzI8wScAiuzlB58 VBZoDDRMBiSehJh2KMxe23dUCFfJss8eXnViq2PX9OcpzV4YtSLgklnaKtior+emCX/e xvOe0eXtdJi8Sm/FwGODod08E9mdrpLr2FTArDWUPdgCIl2wG6mCyGGD6iDZvEeUL3s5 4djyvrc4b2Gml8B05enKrzClZff/1/55JjP+6LElFkU/S7ypnfeQnnYGm9+o9Zy6VPeW 2MQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qftdfNWt; 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 p5-20020a170902ebc500b0018981449921si2400743plg.107.2022.11.30.14.09.33; Wed, 30 Nov 2022 14:09:44 -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=qftdfNWt; 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 S229662AbiK3VkT (ORCPT + 84 others); Wed, 30 Nov 2022 16:40:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiK3VkP (ORCPT ); Wed, 30 Nov 2022 16:40:15 -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 F264445A04; Wed, 30 Nov 2022 13:40:14 -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 8F66A61E03; Wed, 30 Nov 2022 21:40:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E308EC433C1; Wed, 30 Nov 2022 21:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669844414; bh=CxPqTNad3AlmtYDo7JpT7v5xUXJHj6RfoBJEHMwhH4o=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=qftdfNWtJsGXyRqj6DqkV9wyf2IZzm8WHgJixWCFmiHxnUBcG7ZaPFsG+nLb6E89v EG+hNEFxqAegH2emYTG5PoiV7FIvNuUhwpPz9bZXlCTrH49JpHySIoC8ixqDD3zvJ0 iEuf4W5hziEvb++NOCGPv04/ge3zJ9JCmzfexCEG3+Naufvy/Buw4dd4AOUqKWwlrc +Tl1YTtU3mOqM3nq2bddTNOygvi+KDy9C3FYJcb7VVayeGejP7BvYl+XqwFh6Gmtzr dF4xxjcPCVU72pjYDRXR0/9gTqFXf7MAK3y9KA0iH5dmjbcEgFjix2ReMzUSyweWaF gijxBX7IcRn7g== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 8228F5C051C; Wed, 30 Nov 2022 13:40:13 -0800 (PST) Date: Wed, 30 Nov 2022 13:40:13 -0800 From: "Paul E. McKenney" To: Eric Dumazet Cc: Joel Fernandes , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, David Ahern , "David S. Miller" , Hideaki YOSHIFUJI , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Subject: Re: [PATCH rcu 15/16] net: Use call_rcu_hurry() for dst_release() Message-ID: <20221130214013.GT4001@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20221130181316.GA1012431@paulmck-ThinkPad-P17-Gen-1> <20221130181325.1012760-15-paulmck@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Wed, Nov 30, 2022 at 07:39:02PM +0100, Eric Dumazet wrote: > Sure, thanks. > > Reviewed-by: Eric Dumazet Applied, thank you!!! > I think we can work later to change how dst are freed/released to > avoid using call_rcu_hurry() Thank you for being willing to look into that! Thanx, Paul > On Wed, Nov 30, 2022 at 7:17 PM Joel Fernandes wrote: > > > > Hi Eric, > > > > Could you give your ACK for this patch for this one as well? This is > > the other networking one. > > > > The networking testing passed on ChromeOS and it has been in -next for > > some time so has gotten testing there. The CONFIG option is default > > disabled. > > > > Thanks a lot, > > > > - Joel > > > > On Wed, Nov 30, 2022 at 6:14 PM Paul E. McKenney wrote: > > > > > > 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 > > >