Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2815468rwb; Wed, 30 Nov 2022 11:13:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PjhEHfGHVLPwkWbsYLzYrNNORW2akI2a5GoNOxYhWsQt4A2+kbv5bg2WUMXvztqIC5rFx X-Received: by 2002:a17:906:69b:b0:78e:ebb:cbb7 with SMTP id u27-20020a170906069b00b0078e0ebbcbb7mr38894908ejb.38.1669835582529; Wed, 30 Nov 2022 11:13:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669835582; cv=none; d=google.com; s=arc-20160816; b=nOe9IAi8lR6VZre1Yz2uAemNdg+lDemtiqSrdHDGxhoH1ovtNYEM+I1FG3L7wnmwbk hAODjA7Jzb4BsYiC1z2CjS4uDBYfPWd/u3TOrkaF6AEfjs0nbUDITeU65p3iUTttr0O3 8xTQmvb3pEKWF/kBU94cATDome0nJnHAq/9xjdxrkAuA2Xfy363wuj5xF52cnt++/bCz eky4CiNsb0VEGQQt+djDxMdkhNR4eBpuXT7u6qA6E3EUU53QvyndupzWUrsuWxOT0h/g +RgjJ3ZqjEMC+lmFCUa5XXTsZ0CZRFixW+CRIbzD8LlZ2/epH9b5HwjqcswH13DsaiaW Dsvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=OmNYHQ87jUtb5aK4EnCchCezDsC03KpUUikHHBwmz1U=; b=ZFpQi0aVYLI88v5g0nd2Ftdi9nwZ/eMhMcGFogP26G6tS2zHnIL9ENautiFJsNM/dK tGEu/wuGX2DiXaNQRi3DcvmF/zeI5ZUn743PCQYu2IGGJCZ4Yqz/ZnjuvWDfVKZyJXyt gVeDHyt906LBUPORPpx1qgWDPnsv6FVDtvoXh7S1nmcM2v/4xxV32mtccGuniV77/HWa bYaix0N/Fz950DrmzOCLK9umvtmIC+CVw+rqry2pBFNkxB6EnJIG35Z9JpzhsbDDkCgZ a2FMrrf2LW2gnvXOxV39NhaqJVPlq3eQ4rwZmZqwmDZHQbVhrNlVSM7jnU0wNCn9J9U2 EM1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hM8fAGmb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sh8-20020a1709076e8800b007aee592fd06si1912863ejc.203.2022.11.30.11.12.42; Wed, 30 Nov 2022 11:13:02 -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=@google.com header.s=20210112 header.b=hM8fAGmb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230516AbiK3SjS (ORCPT + 83 others); Wed, 30 Nov 2022 13:39:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbiK3SjP (ORCPT ); Wed, 30 Nov 2022 13:39:15 -0500 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 576EC8DFD3 for ; Wed, 30 Nov 2022 10:39:14 -0800 (PST) Received: by mail-yb1-xb29.google.com with SMTP id n196so2729093yba.6 for ; Wed, 30 Nov 2022 10:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OmNYHQ87jUtb5aK4EnCchCezDsC03KpUUikHHBwmz1U=; b=hM8fAGmbVUpSg0bshwhdBqoAETj09emtZtyATn2/YdkJv/RppRRohbgPweefZuAJg3 AggTj8vfGNLhroF4rzrh56LA4EvvnWZlCOfpKgNDBeadr75kfCsf2XXj262T99aH6sFM gdTOqZ5155WfFRf57Uus46Kqd9WTJYWtjwSyt9VUQL5l4fsAc8IKR7SM7YBD7Zc+hhOH IjQon4p4/tt0sPHle1d/rztok1ryFC9JMU8Ud7kiAZMqYA0p7E1fFY3n097+eRrMx+jI O1KxbFpYRtgondwzeZhENJ9nreC1GckW9wVyoLVtrCtum7ihKJ8HXVAHCy82IWrSKfas oevA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OmNYHQ87jUtb5aK4EnCchCezDsC03KpUUikHHBwmz1U=; b=H11wc//phKcAqkBj8Irpz+krbvVSjDdJhGHSZDDE8k/Hxi65Ppt7Ax+yEbyDCWVykE 6hFI4FrDErLdlrJidZOBtlbxo9t7PixQQFfsMlNu+Clb4UCjlKrsEzM2e4k7VX2JD8Cv s7h2KzBGBX2IY9OsE1Wm9wud5mzanVr8uYtExVilsUtOB1Kut0m4B2tQ8D/m9KRIb5xL 2u0M1Vrdrg1p5iWtMBtSiPK0BWz9OcidOS/Ymp7Xbkn1DPC59bkUE/GcJm6hVW/PkVY1 N2eU1aiiW/NUl6PCjjCfbB/FCQtGn0eTeIjs93doaeM/7VIhtrVjVBVuWfLftNa5YgUI UN3w== X-Gm-Message-State: ANoB5pkhM+lBahj0/vQAKgnEK0XxGOSUxjI70mcINmbRWaPcCyXz22yl 7W0W233IprVy8A07OYZoi0s1vehgSNquPPi5lzC0OA== X-Received: by 2002:a25:5045:0:b0:6f0:9f69:6cd3 with SMTP id e66-20020a255045000000b006f09f696cd3mr33343170ybb.407.1669833553217; Wed, 30 Nov 2022 10:39:13 -0800 (PST) MIME-Version: 1.0 References: <20221130181316.GA1012431@paulmck-ThinkPad-P17-Gen-1> <20221130181325.1012760-15-paulmck@kernel.org> In-Reply-To: From: Eric Dumazet Date: Wed, 30 Nov 2022 19:39:02 +0100 Message-ID: Subject: Re: [PATCH rcu 15/16] net: Use call_rcu_hurry() for dst_release() To: Joel Fernandes Cc: "Paul E. McKenney" , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Sure, thanks. Reviewed-by: Eric Dumazet I think we can work later to change how dst are freed/released to avoid using call_rcu_hurry() 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 > >