Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5519620rdb; Wed, 13 Dec 2023 10:55:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzKmyEzZ/PNooO8/o7UMeQWEZPUcj/qxImjinXA8pJr42sPMLf7pFQfk/qkF1bF5wicgp5 X-Received: by 2002:a17:902:f807:b0:1d0:6ffd:e2de with SMTP id ix7-20020a170902f80700b001d06ffde2demr8686026plb.120.1702493741909; Wed, 13 Dec 2023 10:55:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702493741; cv=none; d=google.com; s=arc-20160816; b=qPojons6Jr7eY0ydv1TEO9eNUPti3s4/TaUiGawLI4wVh00Es7aR8FyHEDX0e3ObLj pr+OdxeJdqHE8vBZ+dTPgfpoNokFktK8cH+fA5qk7YvWKacexgGMW248plHDOn0NWQGM 22A+FZIIuIXwa688afXa3DNEBcRugr4N968w/TYZy+P7Gua9AP//8YPUz8jQH5QYx8fr UGkjUjEXI8sKB+qgMhh1p3Jju52Q+eTR662gyVLix+6fbfoV/m8lAGwB4zQGwA6qEz+7 ooObg+TP/h9BbJ4MHU2KBy5INrpwWKu8TslJ7Rv+JfEhSS8fKAbsqcqeLgJx3U4uUv8l pYRg== 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-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=MGK24w/6DODycqVKlIa0sCUTAPossi1v1uRB0bklBtU=; fh=e/OFF91UXV41WM2De3X8gfB/ERAqNJd5LmXwqMoI0dY=; b=g2YDQWMHJu+bN4KIt5gNF1CJgjNfRCegp+Ea2EXg6e+g1Ulcwxxpf1w9GHMMURwjs9 pPL4dO1C5z0xawAJ5YUFdCGuOrcu8rZIDkIB63eJTuy+obX7ExOSBiiodQ6GOd/ZIE/s WXoc3StL8PebN609INr9SMjhS+b0wHROkodTQAUTUz/CjZt00coQm+RB/a/PbVlaDHRt kc2f4mkQqVpmAs/4cGlsyPyw6V7SMVXAhAkKt29W1KaQQkpUXKBcHoJiS8bWuigTw8j3 Mt0ieD8tKYWpzHqGY70LyGprca930T2TgbdZy5d2r5JNjOjXEG1ERY+HTS3hF95a91py 8zcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BLEwHEC9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id p3-20020a170902e74300b001d3622d0c97si377201plf.631.2023.12.13.10.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 10:55:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BLEwHEC9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 4D9A780658FA; Wed, 13 Dec 2023 10:55:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379185AbjLMSy4 (ORCPT + 99 others); Wed, 13 Dec 2023 13:54:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbjLMSyz (ORCPT ); Wed, 13 Dec 2023 13:54:55 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22E02B0 for ; Wed, 13 Dec 2023 10:55:02 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B224DC433C7; Wed, 13 Dec 2023 18:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702493701; bh=gNwdzPsr9UWjlIeXdMO9ihywHKgw6GU/WIg5VvGTAaw=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=BLEwHEC9xexsuNcvGDIs8F1R9mitnFG6BFTwBMIo1YZzyJo76DWKF6wPmO4/EaJ5m HUu9AoGBBPrbm2BPquvJZWg35Q3qJtb5a7l2Ummy744S+2EwCL0yR+ARXGOmEBorxT kzFXM/cNvD20CP1t5fAiIhd8UdZUZAAasA1W+goHjmIzDNH2ao/66M28sMLMRf/D+n 07LPLi4iT7jkAmeWvgGL+jeyLay3u2/0KNHbwuc6uZeqtjo8S4WKIe6WrP3aiysClf CK+b93YBH0HwW0uNT7kAcWvnUKGFKlBth+5Ab3QfYV3W9IwTu2fy4FlcaAPFLkUhFE DuVjVYKghL8OA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 50904CE0C4D; Wed, 13 Dec 2023 10:55:01 -0800 (PST) Date: Wed, 13 Dec 2023 10:55:01 -0800 From: "Paul E. McKenney" To: Joel Fernandes Cc: "Neeraj Upadhyay (AMD)" , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, Neeraj.Upadhyay@amd.com, Frederic Weisbecker Subject: Re: [PATCH rcu 3/3] srcu: Explain why callbacks invocations can't run concurrently Message-ID: <9109c700-a353-4b12-a7c5-2f67e9ab4e86@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20231212174750.GA11886@neeraj.linux> <20231212174817.11919-3-neeraj.iitr10@gmail.com> <2b2c1573-337d-409b-a8ee-daeff096c7f4@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 10:55:11 -0800 (PST) On Wed, Dec 13, 2023 at 01:35:22PM -0500, Joel Fernandes wrote: > On Wed, Dec 13, 2023 at 12:52 PM Paul E. McKenney wrote: > > > > On Wed, Dec 13, 2023 at 09:27:09AM -0500, Joel Fernandes wrote: > > > On Tue, Dec 12, 2023 at 12:48 PM Neeraj Upadhyay (AMD) > > > wrote: > > > > > > > > From: Frederic Weisbecker > > > > > > > > If an SRCU barrier is queued while callbacks are running and a new > > > > callbacks invocator for the same sdp were to run concurrently, the > > > > RCU barrier might execute too early. As this requirement is non-obvious, > > > > make sure to keep a record. > > > > > > > > Signed-off-by: Frederic Weisbecker > > > > Reviewed-by: Joel Fernandes (Google) > > > > Signed-off-by: Paul E. McKenney > > > > Signed-off-by: Neeraj Upadhyay (AMD) > > > > --- > > > > kernel/rcu/srcutree.c | 6 ++++++ > > > > 1 file changed, 6 insertions(+) > > > > > > > > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c > > > > index 2bfc8ed1eed2..0351a4e83529 100644 > > > > --- a/kernel/rcu/srcutree.c > > > > +++ b/kernel/rcu/srcutree.c > > > > @@ -1715,6 +1715,11 @@ static void srcu_invoke_callbacks(struct work_struct *work) > > > > WARN_ON_ONCE(!rcu_segcblist_segempty(&sdp->srcu_cblist, RCU_NEXT_TAIL)); > > > > rcu_segcblist_advance(&sdp->srcu_cblist, > > > > rcu_seq_current(&ssp->srcu_sup->srcu_gp_seq)); > > > > + /* > > > > + * Although this function is theoretically re-entrant, concurrent > > > > + * callbacks invocation is disallowed to avoid executing an SRCU barrier > > > > + * too early. > > > > + */ > > > > > > Side comment: > > > I guess even without the barrier reasoning, it is best not to allow > > > concurrent CB execution anyway since it diverges from the behavior of > > > straight RCU :) > > > > Good point! > > > > But please do not forget item 12 on the list in checklist.rst. ;-) > > (Which I just updated to include the other call_rcu*() functions.) > > I think this is more so now with recent kernels (with the dynamic nocb > switch) than with older kernels right? I haven't kept up with the > checklist recently (which is my bad). You are quite correct! But even before this, I was saying that lack of same-CPU callback concurrency was an accident of the current implementation rather than a guarantee. For example, there might come a time when RCU needs to respond to callback flooding with concurrent execution of the flooded CPU's callbacks. Or not, but we do need to keep this option open. > My understanding comes from the fact that the RCU barrier depends on > callbacks on the same CPU executing in order with straight RCU > otherwise it breaks. Hence my comment. But as you pointed out, that's > outdated knowledge. That is still one motivation for ordered execution of callbacks. For the dynamic nocb switch, we could have chosen to make rcu_barrier() place a callback on both lists, but we instead chose to exclude rcu_barrier() calls during the switch. > I should just shut up and hide in shame now. No need for that! After all, one motivation for Requirements.rst was to help me keep track of all this stuff. Thanx, Paul > :-/ > > - Joel