Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5523161rdb; Wed, 13 Dec 2023 11:01:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8Z3DsjroFPmi5U+aEOMrbvCoIWdVM9z6l8SUKnuXq+eYuJpDbwUzkwvqWMDFA1W1rbv51 X-Received: by 2002:a17:902:c406:b0:1d1:c96a:c5e with SMTP id k6-20020a170902c40600b001d1c96a0c5emr10572769plk.70.1702494114933; Wed, 13 Dec 2023 11:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702494114; cv=none; d=google.com; s=arc-20160816; b=KUj4YhcaudJpJfuZWY6pWXwlQGVZhWqExLFiQbFF7ATTd3vYf93hvlZ5kzGdwgLz5d BIL5k7FhlzcZtuqMlgR7xep0xDkeOGtdLru5dy0DsZa88+Rz4hHjm8bP+zSTw5ZSAnqE 9949gZtRnuZo/zNbmrPkujEefGMUqM7KyaQjXp6fcIdzGX7OIpiWCRYsUrkSmo5JDg+4 Tz94YfHjOFXi0342GEYnsRCfTjgSUK2rGCLkCQnSlzJqoFqKR0ftvyfvjhpW5hsSgv5U 4WfTj3AngXg1VX3envTMtz8/ujuMJAkOlq25+PolUhoG/vp8P2C5mmntUYA6X2mFDl91 G6Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=jk7jO9SMIKHUyFnn0B2awK+sOxOmjadDlSFGy0G4gN0=; fh=PU1tt3fA0kPQUsI8DxubAS4tx12mbD8OKaCjuZdEGVQ=; b=nKEKumjOPvRH/SglE4GxHRlNyBsjh3sgbnyEgMmjDm8DCW2eLcEnS4n3lQRgovRqOc yGOWHbznmT86moZSsQoP9OZmuqW35WoIi4+6Krf7rlVS4On7ueM5gll9JRgl1B4g4WDt U5mGEzfY2oIiYbnOs0QWGw9T+99pLeWG/nr1AK3WwPMOiafRBI4uj46A1bxUYmB25Y6s ASWOls6vN9jxzuerq9X73A/gSxktitqcOtYUPGMc8aKEmPLqMydSGAtoMKRfMlWN9EpN P2ds3kxXpY0SoR29O0JY9aQmcCbisrtu9/6OFdBQM64xu9vOizrYmMGdoDZdPW5ZWde2 gqvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=T+yT1UNp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id w13-20020a170902a70d00b001d0824216a3si9945387plq.432.2023.12.13.11.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 11:01:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=T+yT1UNp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 43AF580BB3E8; Wed, 13 Dec 2023 11:01:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379292AbjLMTBg (ORCPT + 99 others); Wed, 13 Dec 2023 14:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235386AbjLMTBc (ORCPT ); Wed, 13 Dec 2023 14:01:32 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DCA6D0 for ; Wed, 13 Dec 2023 11:01:38 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2cc3602ae44so15480401fa.2 for ; Wed, 13 Dec 2023 11:01:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; t=1702494096; x=1703098896; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=jk7jO9SMIKHUyFnn0B2awK+sOxOmjadDlSFGy0G4gN0=; b=T+yT1UNpiYK7SC5UahJEMuPESFl8dIoAbPqPr7pdXrl6pqSv1/qprMxRSk5PLtMLU/ SAJftnuILQVwbapDZRRl6loUKC+Y+mKI0qg1pTnyH/lNqucDLu8TN2P1nR+QXWUM8VBG yZus09WIQBTen3JZE5GPA/qe5vOrGvlDywiT8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702494096; x=1703098896; h=content-transfer-encoding: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=jk7jO9SMIKHUyFnn0B2awK+sOxOmjadDlSFGy0G4gN0=; b=A4EoDU77arYhg4+2wRYdTv9kfZcFm4DAdWbZVCf5IKxrZVvL0hdcKoH3JksIqCvLir ypg/y0HO+08D4kkVwI/6dSxRRrnZMe8UESJQGrWhPmEjuV1QCg0lzSfFmuVryiN6Fmc8 +7Kv7Dx6SS9JwsseSNKaeyoPGTON5knzLb7+SQW04BdxU0JBDFGe2EHRI35sMz3wJejz SBECwBkCVemsjgspialDbxE/mza4icKvMowyYgBSYjovrq6+V1sixOqxnhZDr7rypuFG pPW/0He9RIXztHn5YrsOeeg+IJbSd05D5IhvMlsw/20rDLo4MagEma9fp0QJU5GxuhPj KjYQ== X-Gm-Message-State: AOJu0YytGclGzpTuCwEzxb7oJgNWnrIENFuqiCx+l29GoH8YwUfoUSy1 ndRh3sYcscNsg/8TH/POIKYiNaLg0/nEbev7o6tuH9xjYSrQ8ho5 X-Received: by 2002:a2e:3909:0:b0:2cc:1fc1:e209 with SMTP id g9-20020a2e3909000000b002cc1fc1e209mr2704810lja.88.1702494096410; Wed, 13 Dec 2023 11:01:36 -0800 (PST) MIME-Version: 1.0 References: <20231212174750.GA11886@neeraj.linux> <20231212174817.11919-3-neeraj.iitr10@gmail.com> <2b2c1573-337d-409b-a8ee-daeff096c7f4@paulmck-laptop> <9109c700-a353-4b12-a7c5-2f67e9ab4e86@paulmck-laptop> In-Reply-To: <9109c700-a353-4b12-a7c5-2f67e9ab4e86@paulmck-laptop> From: Joel Fernandes Date: Wed, 13 Dec 2023 14:01:24 -0500 Message-ID: Subject: Re: [PATCH rcu 3/3] srcu: Explain why callbacks invocations can't run concurrently To: paulmck@kernel.org 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 13 Dec 2023 11:01:51 -0800 (PST) On Wed, Dec 13, 2023 at 1:55=E2=80=AFPM Paul E. McKenney wrote: > > On Wed, Dec 13, 2023 at 01:35:22PM -0500, Joel Fernandes wrote: > > On Wed, Dec 13, 2023 at 12:52=E2=80=AFPM 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=E2=80=AFPM Neeraj Upadhyay (AMD) > > > > wrote: > > > > > > > > > > From: Frederic Weisbecker > > > > > > > > > > If an SRCU barrier is queued while callbacks are running and a ne= w > > > > > callbacks invocator for the same sdp were to run concurrently, th= e > > > > > RCU barrier might execute too early. As this requirement is non-o= bvious, > > > > > 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 w= ork_struct *work) > > > > > WARN_ON_ONCE(!rcu_segcblist_segempty(&sdp->srcu_cblist, R= CU_NEXT_TAIL)); > > > > > rcu_segcblist_advance(&sdp->srcu_cblist, > > > > > rcu_seq_current(&ssp->srcu_sup->src= u_gp_seq)); > > > > > + /* > > > > > + * Although this function is theoretically re-entrant, co= ncurrent > > > > > + * 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. Got it, reminds me to focus on requirements as well along with implementati= on. > > 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. Right! > > 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. Thanks! - Joel