Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp208497rdf; Thu, 2 Nov 2023 19:54:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuoT+JtW2qLMqGdlMGxOczkjrmgdh27PP8jx1WOvwg76KYnzNVomAZMi4LJMQ9niYwWXVa X-Received: by 2002:a05:6358:716:b0:168:e8f9:abca with SMTP id e22-20020a056358071600b00168e8f9abcamr15386261rwj.31.1698980066878; Thu, 02 Nov 2023 19:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698980066; cv=none; d=google.com; s=arc-20160816; b=bPJYrV3ODA0ONeHxgcwKxlFo8/0P30hiTOoInXLCzn7MaLNxNpMQG865WSUx3K8DMP 4B7QH/895csQHw1ZXX/81T+TlJpKNIL2IfLnExwELdvEc+JLHaHmYTgfkg28OiVPYsJb jleseG4SETA+h2pWIEDmv4TE7GeJn3QUnQ6ZkMbNB4GfSOOpRxtVT9ucR3FotCRsHDUg IqGRdZ4KWS2uCNGafZ7uzm7sE73nDdANqSHccLaMyMeV96AIRCLiehNmH2bTWTLatO7w ZUvBEikyO480dS9OilQBinMvv0U8OXitypbhslIH3sucR1W+Bi0PgLwY/MDGk1IiYczn KBjw== 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=t1urYMGJtezmEEkYq8qONk+NYpmVPri9LBlkcnxgbB0=; fh=60jl8KwQJTNEsGxRfoVaZmKiRuglYvIovS2YUW+CsZE=; b=aESiqEiqUnIAnA/4L7miasmmseZCQD6ES6oTVayxPGFqdxRd7WYc3+oBsbhJP8rSS7 b/1+lt521rkU5YnhzhasLo5WG8N2ONxF+gu/sDmxKmKbKw/CrF5Oc88GxPPhqKVzS/NS a+Or1b6dO1RU5PQpaKLsFsMmwET8CpsBn+OvrLzhD1/SExbAcRGHcFmF00tf6/BqQTiF D4axRdOMOC0VQjtKj97PEWaZLq9IveRBszhT5l3RvonyO369lPx35Q+HOG1qX258gilz X0zn1TmnsvCvOYCKO3hXL0Qvv4kpNjjnj4jkTQ5UUAieqKTnIK/OugxIzLvJ/aaLmcqs 5Y7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VIJo5VYh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bo11-20020a056a02038b00b00585999a38a6si695565pgb.793.2023.11.02.19.54.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Nov 2023 19:54:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VIJo5VYh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id ABE808253FE8; Thu, 2 Nov 2023 19:54:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbjKCCyV (ORCPT + 99 others); Thu, 2 Nov 2023 22:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjKCCyU (ORCPT ); Thu, 2 Nov 2023 22:54:20 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0340E19E; Thu, 2 Nov 2023 19:54:18 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A0F4C433C7; Fri, 3 Nov 2023 02:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698980057; bh=WjCKWJ96urD0RbWA8/NzLzQQE0vm/ybcf+n2HE8KzMM=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=VIJo5VYhf0/+2yGmAK/8Ial6PVc66jrWJv5Tu8ZWmaJiYG+UmMEgB2HxLd9fbaTdk n/npQ+/R5ZaDRzkim5/xuC3dpP7eIfJEjFsp/UQ+TloEcsdretgP4UuNjM2iA0rqqN viknD057v7MHZVo3VplCjrDMrXyKs1iDppRmVg1EUgmQZYRkTP/+h4vzOFSQyOGTyM Rke6VvWeqnBA+co2eOmwxnODGAd9JuVcCchNstmxuimW98UoQWQw3pgpWt6mTFtu0M lN/kQsbWEle8ZFyE4QY4bzZKn0cj79ur7lp8245fogSBLZVXXoz0j+TybbT6mUl0E8 pQqnCW+hyeppQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 22C33CE0F7A; Thu, 2 Nov 2023 19:54:17 -0700 (PDT) Date: Thu, 2 Nov 2023 19:54:17 -0700 From: "Paul E. McKenney" To: Zqiang 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: <9f15280f-45a3-4e3f-832d-cea5c77eb449@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20231101033507.21651-1-qiang.zhang1211@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231101033507.21651-1-qiang.zhang1211@gmail.com> X-Spam-Status: No, score=-1.6 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 02 Nov 2023 19:54:24 -0700 (PDT) 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? > /* Funnel through hierarchy to reduce memory contention. */ > rnp = raw_cpu_read(rcu_data.mynode); > for (; rnp != NULL; rnp = rnp->parent) { > -- > 2.17.1 >