Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2604149rwb; Thu, 17 Nov 2022 13:15:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf7bOrWmtdzBeP7Z1gIBYDIjM9FLiBm1pm6vtfgmFf8N9Zkq+FI1O/1zS2C+w1R3bSC4DjpG X-Received: by 2002:a63:1626:0:b0:470:2c90:d89f with SMTP id w38-20020a631626000000b004702c90d89fmr3855504pgl.253.1668719743119; Thu, 17 Nov 2022 13:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668719743; cv=none; d=google.com; s=arc-20160816; b=IwOUhJTs9EAUyMlbzWhL2afGW9WXCj0fXLbZN3ifPnrN37V8uPYopb+Qcu3UNV678D +G5gr16FP2vcKRON0yH1cVrf1IBC599V1CLiQ+2+f3AZQRGs6Mn4uWxX2l0DJqOID0MY 51lCYFPZtiYA2GZz0bVCQTsMR1B+T7R7Iv3D5Yq6dmjW1BIjDB9KTtf8pDEsZqdLMi08 F6/9yvlaPVS+muHJ3dhwdVfJGWHZfspmvYQXoOPHgR2T8CuC2nP7SdQz9L5eyVqi7rRP CowtbBEaMe2Z4U1W96uh8Ef0y68oIfHa6ztBmqfkapS3s4qSl6Ozy9xqNzEx/+hQWVsN iJtQ== 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=f5544AIJrDskL6W6qw8209ruFTt+If3yk/f/hXPZ2p0=; b=l1MOHcofFdeiawh4DRl9rlQaNSZ/hUIIEPAsYuGU2EiYQ14AiXCu/cpuSf+IKEsA73 81baGczcUJhDskZMwLjtxamyaBGJChFcBW7zPhZTT+TtRAxpOFE/IqrVstP28jrM5xmz VMQ/ZZpQSPmNTwlHRglmD+jv8IJ8BmV46Du8eOwuzJ+0L4ioH3Q+D0P9OcHmGObq0J3m FKCYBXrW7t0dbEwNRkjhbAQ2hTTuWbkO+nyjPGUO8CTUCRk/EjdB3D1z9GAscDJKkWAm k9EpQp/sqlCuERcGymFKI4XHA55OOmg4ylsO9Vk67Jx+2HgPFJYOU7gJSFgD3fPsnIVB h76w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dj7BRCZy; 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 f20-20020a056a001ad400b00571ea18493dsi2030140pfv.175.2022.11.17.13.14.59; Thu, 17 Nov 2022 13:15:43 -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=dj7BRCZy; 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 S239263AbiKQT35 (ORCPT + 92 others); Thu, 17 Nov 2022 14:29:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234898AbiKQT3v (ORCPT ); Thu, 17 Nov 2022 14:29:51 -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 F00C36E545; Thu, 17 Nov 2022 11:29:50 -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 8D1116223A; Thu, 17 Nov 2022 19:29:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4E0BC433D6; Thu, 17 Nov 2022 19:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668713390; bh=Lm2cK6bMT7tq+2nS6/7AlfFyPHgdLg/UIO51cboi93w=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=dj7BRCZyZCT3JmqB8RVy9xrPmPCejgVJWQcJUqPDL0xOJTpr5e27m1KGrb/Jvc4xp AM/uFeh8o4xmenloifPk/WT7DUw+2fVSq7nXuvM3PINFXOuJ9XINWR87kkZt2cLtSI GFF874LNhWPj+w2lpzeGztbuaNDlanDrzjq6mGa1atgH4RLXgHjShRIgRl3bAEZknl 7gZcWMa7FZ/awB5N+rxOJcx1tYx1orXi+Uz/5h4YLZx9Q+P3AtALV1J+GHqNdeus7w 60V2uoVbHRudWg8b3O20Sz66Wcz9tySi/U61I0r9KuHBU9unoimOyr7kAubitdgRQ+ y3l/m+yqG6leA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 8FDE35C05C5; Thu, 17 Nov 2022 11:29:49 -0800 (PST) Date: Thu, 17 Nov 2022 11:29:49 -0800 From: "Paul E. McKenney" To: Joel Fernandes Cc: Eric Dumazet , linux-kernel@vger.kernel.org, Cong Wang , David Ahern , "David S. Miller" , Hideaki YOSHIFUJI , Jakub Kicinski , Jamal Hadi Salim , Jiri Pirko , netdev@vger.kernel.org, Paolo Abeni , rcu@vger.kernel.org, rostedt@goodmis.org, fweisbec@gmail.com, jiejiang@google.com, Thomas Glexiner Subject: Re: [PATCH rcu/dev 3/3] net: Use call_rcu_flush() for dst_destroy_rcu Message-ID: <20221117192949.GD4001@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20221117031551.1142289-1-joel@joelfernandes.org> <20221117031551.1142289-3-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Nov 17, 2022 at 05:40:40PM +0000, Joel Fernandes wrote: > On Thu, Nov 17, 2022 at 5:38 PM Joel Fernandes wrote: > > > > On Thu, Nov 17, 2022 at 5:17 PM Eric Dumazet wrote: > > > > > > On Thu, Nov 17, 2022 at 7:58 AM Joel Fernandes wrote: > > > > > > > > Hello Eric, > > > > > > > > On Wed, Nov 16, 2022 at 07:44:41PM -0800, Eric Dumazet wrote: > > > > > On Wed, Nov 16, 2022 at 7:16 PM 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 > > > > > > > > > > And ? What happens then next ? > > > > > > > > The test is doing the 'ip netns del ' and then polling for the > > > > disappearance of a network interface name for upto 5 seconds. I believe it is > > > > using netlink to get a table of interfaces. That polling is timing out. > > > > > > > > Here is some more details from the test's owner (copy pasting from another > > > > bug report): > > > > In the cleanup, we remove the netns, and thus will cause the veth pair being > > > > removed automatically, so we use a poll to check that if the veth in the root > > > > netns still exists to know whether the cleanup is done. > > > > > > > > Here is a public link to the code that is failing (its in golang): > > > > https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/tast-tests/src/chromiumos/tast/local/network/virtualnet/env/env.go;drc=6c2841d6cc3eadd23e07912ec331943ee33d7de8;l=161 > > > > > > > > Here is a public link to the line of code in the actual test leading up to the above > > > > path (this is the test that is run: > > > > network.RoutingFallthrough.ipv4_only_primary) : > > > > https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/tast-tests/src/chromiumos/tast/local/bundles/cros/network/routing_fallthrough.go;drc=8fbf2c53960bc8917a6a01fda5405cad7c17201e;l=52 > > > > > > > > > > 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. > > > > > > > > > > What is this test about ? What barrier was used to make it not flaky ? > > > > > > > > I provided the links above, let me know if you have any questions. > > > > > > > > > Was it depending on some undocumented RCU behavior ? > > > > > > > > This is a new RCU feature posted here for significant power-savings on > > > > battery-powered devices: > > > > https://lore.kernel.org/rcu/20221017140726.GG5600@paulmck-ThinkPad-P17-Gen-1/T/#m7a54809b8903b41538850194d67eb34f203c752a > > > > > > > > There is also an LPC presentation about the same, I can dig the link if you > > > > are interested. > > > > > > > > > Maybe adding a sysctl to force the flush would be better for functional tests ? > > > > > > > > > > I would rather change the test(s), than adding call_rcu_flush(), > > > > > adding merge conflicts to future backports. > > > > > > > > I am not too sure about that, I think a user might expect the network > > > > interface to disappear from the networking tables quickly enough without > > > > dealing with barriers or kernel iternals. However, I added the authors of the > > > > test to this email in the hopes he can provide is point of views as well. > > > > > > > > The general approach we are taking with this sort of thing is to use > > > > call_rcu_flush() which is basically the same as call_rcu() for systems with > > > > CALL_RCU_LAZY=n. You can see some examples of that in the patch series link > > > > above. Just to note, CALL_RCU_LAZY depends on CONFIG_RCU_NOCB_CPU so its only > > > > Android and ChromeOS that are using it. I am adding Jie to share any input, > > > > he is from the networking team and knows this test well. > > > > > > > > > > > > > > I do not know what is this RCU_LAZY thing, but IMO this should be opt-in > > > > You should read the links I sent you. We did already try opt-in, > > Thomas Gleixner made a point at LPC that we should not add new APIs > > for this purpose and confuse kernel developers. > > > > > For instance, only kfree_rcu() should use it. > > > > No. Most of the call_rcu() usages are for freeing memory, so the > > consensus is we should apply this as opt out and fix issues along the > > way. We already did a lot of research/diligence on seeing which users > > need conversion. > > > > > We can not review hundreds of call_rcu() call sites and decide if > > > adding arbitrary delays cou hurt . > > > > That work has already been done as much as possible, please read the > > links I sent. > > Also just to add, this test is a bit weird / corner case, as in anyone > expecting a quick response from call_rcu() is broken by design. > However, for these callbacks, it does not matter much which API they > use as they are quite infrequent for power savings. The "broken by design" is a bit strong. Some of those call_rcu() invocations have been around for the better part of 20 years, after all. That aside, I do hope that we can arrive at something that will enhance battery lifetime while avoiding unnecessary disruption. But we are unlikely to be able to completely avoid disruption. As this email thread illustrates. ;-) Thanx, Paul