Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp664445rdf; Fri, 3 Nov 2023 11:07:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3RAp8uc8DVDiU6mkkh+jCYO2TwyHfMbmX5TsJTFUnXNvpY5wg5q+97uAtDjs20okLxZPe X-Received: by 2002:a17:903:120b:b0:1cc:7e40:de4a with SMTP id l11-20020a170903120b00b001cc7e40de4amr9094437plh.58.1699034839018; Fri, 03 Nov 2023 11:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699034839; cv=none; d=google.com; s=arc-20160816; b=UCcBXuvEJ59r39g2j9TxYe6LmUC+Qfz1+NV0PBPkZN2MCdqfhV1pKCpuVqxhkjENkS grqQ8sLqxXKmruxjQfcBh6fHAnkl2i6FpfIpY7W9puijrPoEapiunj/63u1W0MORBLem 5JQ9pjX/MkVzVyTzc+XCiaOl/0JAIS5NFUhE/4fL4RsBQ1d1V+Y9s71Nvvnx2nZMCZ1i 3vciYGwhQdxzGfDVqHg2b/SF58/tVYoGDkHi58Z9enEsjQBkTDk1adNXJCWPHwHgS5z/ H74wXH0OxJ+XoR/rPlhEct2httyXBZRI28XBlB0PU2yC1xftPPqKzETpVR9potekOe/p j3kQ== 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=j7vuDuhPHT5+PlWo4jN7q+6i2U/7/JxdL/5R6FnP/Dw=; fh=luxRwjtLk3GZfYCW/YPxyLVq55oP8hSzced6b9m2Asg=; b=KdSsdhqLreqitpB4y/83SpSCPfmAji4PQepeNE+fBIFwOGn5USti8gAvU8LxNKgDEf xJj2wI9bR86TxX1fiX5Uw5H/lQ4eNMkNbRlYiNLnB6MAkEchzCPMSrYhtLUyimXqM2Ip SJPLf26KH1ZsqJuEDQFFYA8tHRgNYpAr/CbeJIgWN0eDQT+dsOZjG3FywMYBkEq5anDA 02kspY843xHccsa00nOHwVG8Xll+phDizMipwOJl8OjAvvd2tmkTYF7nJ4Rmlau0sVDN svZW4yfvwdfeXOwyziWx+ry6//0X/Gwe+F/eL8/hroRbDIuunrScQ4mQpvLvkYgysH6O uypw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pt93r4Xh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id d15-20020a170903230f00b001c74d1da69csi2113619plh.362.2023.11.03.11.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 11:07:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Pt93r4Xh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 6D8A0807828F; Fri, 3 Nov 2023 11:07:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232849AbjKCSGa (ORCPT + 99 others); Fri, 3 Nov 2023 14:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230197AbjKCSGa (ORCPT ); Fri, 3 Nov 2023 14:06:30 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A18FC1B9; Fri, 3 Nov 2023 11:06:27 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F98BC433C8; Fri, 3 Nov 2023 18:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699034787; bh=IFDcXU62Y6AY7KAbz4GH/eO1AKs/ZOiOmheqQ7Q3C1E=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Pt93r4Xh2Uxy0VwYyvbPFkC9AdQxRrNNB9x0zkJLXhJ5wgP8xMDOecChJde5pgwgX kDQOWtHylnwOBmM0CupcRMgHwT2OcYRvLxhtmMnE9XLwZMj2VMn6WXZXEdf+rquCNc RNon4t/nPnLR8sLTeXjoAmciF+0klYR+929uMqDn8rry41BmcSAEizX5wRhk39R6IZ /7UqEjuVQMl8AjnoCWrjZE4jN3iQlj4A9ztngPawb13rVjw/5rx8UVPA0zZwfU6F14 b8DKoSmhtP6FOb0oBztarLUT1UFa1MsvtNRrWjcN8qFijWEjMm+WA+2QrW5emFJchi k7RMLA0NBM8eQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id E3624CE0D1D; Fri, 3 Nov 2023 11:06:26 -0700 (PDT) Date: Fri, 3 Nov 2023 11:06:26 -0700 From: "Paul E. McKenney" To: Z qiang Cc: frederic@kernel.org, joel@joelfernandes.org, boqun.feng@gmail.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rcu: Force quiescent states only for ongoing grace period Message-ID: Reply-To: paulmck@kernel.org References: <20231101033507.21651-1-qiang.zhang1211@gmail.com> <9f15280f-45a3-4e3f-832d-cea5c77eb449@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 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]); Fri, 03 Nov 2023 11:07:05 -0700 (PDT) On Fri, Nov 03, 2023 at 03:14:11PM +0800, Z qiang wrote: > > > > On Wed, Nov 01, 2023 at 11:35:07AM +0800, Zqiang wrote: > > > Currently, when running the rcutorture testing, if the fqs_task > > > kthread was created, the periodic fqs operations will be performed, > > > regardless of whether the grace-period is ongoing. however, if there > > > is no ongoing grace-period, invoke the rcu_force_quiescent_state() has > > > no effect, because when the new grace-period starting, will clear all > > > flags int rcu_state.gp_flags in rcu_gp_init(). this commit therefore add > > > rcu_gp_in_progress() check in rcu_force_quiescent_state(), if there is > > > no ongoing grace-period, return directly. > > > > > > Signed-off-by: Zqiang > > > > Nice optimization, but one question below. > > > > Thanx, Paul > > > > > --- > > > kernel/rcu/tree.c | 2 ++ > > > 1 file changed, 2 insertions(+) > > > > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > > index aa4c808978b8..5b4279ef66da 100644 > > > --- a/kernel/rcu/tree.c > > > +++ b/kernel/rcu/tree.c > > > @@ -2338,6 +2338,8 @@ void rcu_force_quiescent_state(void) > > > struct rcu_node *rnp; > > > struct rcu_node *rnp_old = NULL; > > > > > > + if (!rcu_gp_in_progress()) > > > + return; > > > > Suppose that the grace period that was in progress above ends right > > at this point in the code. We will still do the useless grace > > forcing of quiescent states. Which means that this code path > > does need to be tested. > > > > So, when you run rcutorture with this change, how often has the > > grace period ended before this function returns? If that happens > > reasonably often, say more than once per minute or so, then this > > works nicely. If not, we do need to do something to make sure > > that that code path gets tested. > > > > Thoughts? > > Thanks for the suggestion, I will add some debug information to test again. Very good, and I look forward to seeing what you come up with! Thanx, Paul > Thanks > Zqiang > > > > > > /* Funnel through hierarchy to reduce memory contention. */ > > > rnp = raw_cpu_read(rcu_data.mynode); > > > for (; rnp != NULL; rnp = rnp->parent) { > > > -- > > > 2.17.1 > > >