Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30775763rwd; Thu, 6 Jul 2023 10:29:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlEafmLngbFHubMpO4n561fyNYbDaKN05c49r3pNS/ohMDp410g5D627fVziDmRb8MSd3g3Y X-Received: by 2002:a05:6a20:12d3:b0:122:8096:7012 with SMTP id v19-20020a056a2012d300b0012280967012mr2110606pzg.3.1688664585894; Thu, 06 Jul 2023 10:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688664585; cv=none; d=google.com; s=arc-20160816; b=fpe3wfLubIQgnXBNkBOTwS2/VyM3n7T7KwxD6qjaq5bovD05pqI9UuVnMyGzSu0nh9 +2RWvvb6DcqZeIeeZD//H12Ub13c8UdaL2RigbExdh+m9ZxMPc3CxuWtp+PAJIf2Z3ur PlqokM69rylPtzIL6mbNepwFCF5HJS96MCexXFpjZcEnqyAXcxMisBA3oiN6XUDS2Aq4 q3+WHlNcrsB7OgPMqE45VJaj+r0/wtKRERnrd35WI++vq530SeIP8JwPUyBHjOHvjMdI jNM37TBNCKzegaQva5zt+N+3wnsQYzS0cBEZ6+XCh695Uc2OnJiTvP17pYp+rBDphEht +jRA== 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=EGNVpjsKDmPbCRfNe5XpxVxH7KQ+7lSIElWf4UL8vbI=; fh=fGj9rmzYgm3BgH726RNFc4BPGtVvFW334quBT+cRQAg=; b=gbv155+DBZYMmkkqGuIJJJfkojmHkym12z81cfmbKT0XnzHHH/66RLOaQ+RNC+o3Od OWRqD7twZHQA2C7WHbqv9l3zJT9VNJ3F8V2DQn8kWvLutElbb2WiiCSUTWiLpy6x9wV5 ir3SRrnmT7C0L+b+JoEkOnAYmLdMb0k8jqzfkSMOf+J4j7TgACehkQMNr/wk8jtNTeFn oQ3jhCFcR6L0gxiuBwIVGm5fZhdPKjtaNkaeV0aB95mRILfLkIZzX9IpHPNYYXo0B328 Y9hcd2yPirS4Ssu7jOx8mUJWqsrCsQoB34KGRzo3NK95un1tAPXen7khEZA3ZV6TSqDO GfpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Oql36+gi; 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 n8-20020a170902e54800b001b7ea20dbf2si1807090plf.224.2023.07.06.10.29.31; Thu, 06 Jul 2023 10:29:45 -0700 (PDT) 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=Oql36+gi; 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 S232484AbjGFRIf (ORCPT + 99 others); Thu, 6 Jul 2023 13:08:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232480AbjGFRId (ORCPT ); Thu, 6 Jul 2023 13:08:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 330FC1BFC; Thu, 6 Jul 2023 10:08:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C60F060F64; Thu, 6 Jul 2023 17:08:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24E2EC433C8; Thu, 6 Jul 2023 17:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688663308; bh=BLriyU2lQdQ+9jLmtcnnU/JwBhc5ejNM5/UtXol14aI=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=Oql36+giQ1DnHS9/DvZeYxbWptAdZctYcjpnhXtp2ULoVSNifM2Dvjo4OHE2rMBZi a2ayofrQXX1z1Wu24D5HbITvkO1lJUFVrcESdEy8QzFtRHrpPIShBMbDtCG4o75GaA 6vpuOFhwbusmkh++dEqUJzNKrRfd5fmpCBCuXJeyWQE2Zi27NJI/xTS7uCwB7p+BGT R3FniIxECXHWjAVeTWoVvK7Czp+zZ9oY3mBQRKYAxntkRPtCpc8YKf970ltBPFcEgP wnuulv42lxCjq63fcXA1oAbrVDMCkk4Tb+RwODpskPvzDUfn+C5bRqnQz6mX/TY5fB YuzSmlmi6P73A== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id AF8FFCE3A5C; Thu, 6 Jul 2023 10:08:27 -0700 (PDT) Date: Thu, 6 Jul 2023 10:08:27 -0700 From: "Paul E. McKenney" To: Zqiang Cc: frederic@kernel.org, quic_neeraju@quicinc.com, joel@joelfernandes.org, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] srcu: Make srcu_might_be_idle() take early return if rcu_gp_is_normal() return true Message-ID: <77d16cbb-b28c-4b13-aecb-9ad787559557@paulmck-laptop> Reply-To: paulmck@kernel.org References: <20230704082615.7415-1-qiang.zhang1211@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230704082615.7415-1-qiang.zhang1211@gmail.com> 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,T_SCC_BODY_TEXT_LINE 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 Tue, Jul 04, 2023 at 04:26:15PM +0800, Zqiang wrote: > When invoke synchronize_srcu(), in the srcu_might_be_idle(), the current > CPU's sdp->lock will be acquired to check whether there are pending > callbacks in the sdp->srcu_cblist, if there are no pending callbacks, > probabilistically probe global state to decide whether to convert to > synchronize_srcu_expedited() call. however, for the rcupdate.rcu_normal=1 > kernels and after the rcu_set_runtime_mode() is called, invoke the > rcu_gp_is_normal() is always return true, this mean that invoke the > synchronize_srcu_expedited() always fall back to synchronize_srcu(), > so there is no need to acquire sdp->lock to check sdp->srcu_cblist and > probe global state in srcu_might_be_idle(). > > This commit therefore make srcu_might_be_idle() return immediately if the > rcu_gp_is_normal() return true. > > Signed-off-by: Zqiang > --- > kernel/rcu/srcutree.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c > index 20d7a238d675..aea49cb60a45 100644 > --- a/kernel/rcu/srcutree.c > +++ b/kernel/rcu/srcutree.c > @@ -1172,6 +1172,8 @@ static bool srcu_might_be_idle(struct srcu_struct *ssp) > unsigned long tlast; > > check_init_srcu_struct(ssp); > + if (rcu_gp_is_normal()) > + return false; Again, thank you for looking into SRCU! I am not at all enthusiastic about this one. With this change, the name srcu_might_be_idle() is no longer accurate. Yes, the name could change, but any name would be longer and more confusing. So unless there is a measureable benefit to this one on a production workload, I cannot justify taking it. Is there a measureable benefit? Thanx, Paul > /* If the local srcu_data structure has callbacks, not idle. */ > sdp = raw_cpu_ptr(ssp->sda); > spin_lock_irqsave_rcu_node(sdp, flags); > -- > 2.17.1 >