Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2827979rwb; Wed, 30 Nov 2022 11:24:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf4jS9Xm2GfIPEFN792jenDc1frJNqCST9wO/UylzHFd759++r7QvZzPG/Pdnaz0FFjnw5Et X-Received: by 2002:a17:906:6992:b0:7c0:a880:d569 with SMTP id i18-20020a170906699200b007c0a880d569mr1519696ejr.414.1669836257800; Wed, 30 Nov 2022 11:24:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669836257; cv=none; d=google.com; s=arc-20160816; b=qqsppgZovJ7G+hn46vLkWBQzmbtKbn6/McqYzVIjE86Zb00jFdfmAbF8qXDYWCJbeI 63r1APYQgB29f3uqVdBM70Oh+ySZrEJX4SwgHUb+BhDW46vaxW5Ejb9tqkgnoJO7aCGy CwwIHM6CkSNBqhAPUiQCGyOR+drOFN/0O4J9Keju0KfF8EpRUP/0hLaFxpaRsv3v7Bg3 c1qxUkLfBrUPsQjoP+fjEvyezt6IiSl+O6CLlYDSVHDVioSaQ+EhuNHqXvUTOcYipF9w 5ExioAW4pF2y2w9aprAsrASgY5lJ5OzaLkiwUMAszleYGWfxmKmapETU1SrNBQ6yed6o tiVA== 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=vRCw5HgdZ6+i+5rxJnQV5DsJbEr03vS+VFP709b7Mj0=; b=m1soPUEYoN1DXwqX4KVEWuu0nqvGF2R/XRYsvm2j6nGXm8XVLgPnMWq3mtjjF88dcs YMiVmYO9UDZugnjqXe1A3izzUeTWYjNefqXbdPnByHA5piP80nyvtjHj4rLV98kbrS+e smAI5jf8qv+93nUpo7BzLDYaH9Tq1SxqLJfSSzhQvNezaLgEkrYscfcmNQArr2Y/l+WM u8I1ZT2uldHZm7ar1xN3ZudHQF3mfpas5h8tdWc9APryRIiyuUSRgqC0IBvNke9rD+yH m4L97au3EbI918Q8vlvnNOB73D64KSwO2pW5ZRZlGfQEMEhSa6E/hKN19cer98N3a8KZ 8R9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Fj7wpBqf; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 3-20020a170906328300b007827639faffsi1451697ejw.760.2022.11.30.11.23.56; Wed, 30 Nov 2022 11:24:17 -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=Fj7wpBqf; 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 S231473AbiK3Su1 (ORCPT + 84 others); Wed, 30 Nov 2022 13:50:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231483AbiK3SuT (ORCPT ); Wed, 30 Nov 2022 13:50:19 -0500 Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 826229B7B8 for ; Wed, 30 Nov 2022 10:50:18 -0800 (PST) Received: by mail-oi1-x235.google.com with SMTP id t62so19717750oib.12 for ; Wed, 30 Nov 2022 10:50:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=vRCw5HgdZ6+i+5rxJnQV5DsJbEr03vS+VFP709b7Mj0=; b=Fj7wpBqfoKfCWqoddByeKCliiIhXWseC/prDubeJZMHCNycQ02GhMtCAVmR9tcFjFj DfBiUniDNdOT01JiTghH+KQH04DHEJeuVOsDZEQT+Yg17EVcIlDdDcHWVQZFvMcW6Ikn SBXzsr3nawMrT0TrxZz9eHu4IhIqN5adlS11Q= 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=vRCw5HgdZ6+i+5rxJnQV5DsJbEr03vS+VFP709b7Mj0=; b=y0jC1OAGLuX7hkid4cGpsbqZzxWBYZQ9Mm9I6eTBCwcDACVr64qw5pu+IISl+5kp/3 fplTQGLm89E11Mi5kqGLgSWYeKTVskGY8EfFyOBhm6e3YZsXImFBTvpe1qWINUAD+1po b/RqBp7ZERsHbQKhNMNN68dq0p1gvbF3RnZgWbAzhI2cECU6jL8Zc9kYFVc8B6LCEmEw swaxa6r7fgNqaWxiJC7eCx4iA5DV/ipBiMJDFo1+1xVg9px2nQ/u7AFBMmN8NwS8Pc6s /0kmjorlTEXuCzYpfiV3DCN9v3YZUHHpR5gHPgF1KSDTdglZAK7sAGXpwzbiWD+Sqt6Z PB6g== X-Gm-Message-State: ANoB5pkiFcfRh+/+nMZE4ZQLRopyb1DWe7Mt7T3iFQvvNvX587fRzSk/ cKw6XASnB0QQN1jxHMOffmRHXsza9PTuBbGQzknWYw== X-Received: by 2002:a05:6808:46:b0:35a:ff1:bf0d with SMTP id v6-20020a056808004600b0035a0ff1bf0dmr22785001oic.115.1669834217790; Wed, 30 Nov 2022 10:50:17 -0800 (PST) MIME-Version: 1.0 References: <20221130181316.GA1012431@paulmck-ThinkPad-P17-Gen-1> <20221130181325.1012760-15-paulmck@kernel.org> In-Reply-To: From: Joel Fernandes Date: Wed, 30 Nov 2022 18:50:06 +0000 Message-ID: Subject: Re: [PATCH rcu 15/16] net: Use call_rcu_hurry() for dst_release() To: Eric Dumazet 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=-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: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, On Wed, Nov 30, 2022 at 6:39 PM Eric Dumazet wrote: > > 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() That sounds great, if you can give me any high-level guidance (in the future) on that and what to look for, I can give it a try as well. I have been wanting to learn more about the networking code :-) Thanks, - Joel > 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 > > >