Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32802739rwd; Fri, 7 Jul 2023 22:38:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlF/v0TdSqO5YEBH8Rm8kb0ptYMXBKtbZYFtPXsvL+XtlJpo1qpdUsEvkl8bUZo/EohnGNjs X-Received: by 2002:a92:de44:0:b0:346:49bd:7b6b with SMTP id e4-20020a92de44000000b0034649bd7b6bmr3087302ilr.25.1688794709539; Fri, 07 Jul 2023 22:38:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688794709; cv=none; d=google.com; s=arc-20160816; b=O2o1yjiPhH7Drm5y19tY7HXV0oHLbdsH3bV610M9MPGPuGq7KCDYt/FDIeGweEQCpe 0Nxo5FY5YM73IOkgo12iqtmxcaX9RBr58pllE4kcxrI3dWr7O9m7TQawitQweReXXL8O UD5jN94dHBvoIOIk496RRsPS1OaSxE6ubinw5Lc6cuXPcMXSNeIRnBF3U61W5JZexzTO fvdD3m9srVxGb4pD0bBpy8jb61oB+85s3LbK4cZng/gBD9Hvmlo5NFrVgle0+8/aawBh M0eDDeILwL2xi5Z6CtHNFMZ3iKzU7Z3YQUn2AHnmmhfxJDdphOWCmTCDqH96z6fy/ElK 6S8A== 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=nuUCFUJx0kbxhqkKtSmV6jPPCXqI8172m8/nukGNIF0=; fh=8aibcWqlJmYEpZyC2DE9HocguhQaL3vFHV/JnvKm3Q0=; b=hflJZeFSOfrFLNl5/pb40sd6jzpK3mlcF4o0iWEWcwTclRxtrC1feMKPTa8OCD3KeA xWcjyWGqUpfdv1xJynb1hp8kDTiHsYa+M1dAfsOgTjdmtgmdLNycBupt1CFDpa1h0QvA Cu9rHIcmpOuPOPF8mNKL+yJ6dNapYFeyVlUPf05s2yqaN4+aiMb8aai/scBU9JL2sCVN 3BDLH/iZnUdcyrsDEuDPwTeU4cqra1FzR0J/ptQ0J2MPjpRazdVskCuIVQG3ChFLh0tR E++R55Bfl03HGKQwM8T7GMFpJcMjSZ5PgN0lEAkIEBQS2urW0QGKwKm0V/sgyLbrcLGq ta3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qEoys0Wa; 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 h15-20020a63c00f000000b0055b61cd99a3si5330481pgg.635.2023.07.07.22.38.17; Fri, 07 Jul 2023 22:38:29 -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=qEoys0Wa; 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 S232561AbjGHE4u (ORCPT + 99 others); Sat, 8 Jul 2023 00:56:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjGHE4s (ORCPT ); Sat, 8 Jul 2023 00:56:48 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1A21992; Fri, 7 Jul 2023 21:56:47 -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 64B4B60180; Sat, 8 Jul 2023 04:56:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92CAEC433C8; Sat, 8 Jul 2023 04:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688792206; bh=jIH7Dfx3OwyzpblB1J6hrgpIP+zaCBKcXWS7lbXyui0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=qEoys0WaXmk7pNR5ZPtpF8oo5PmqL7P4as5nypl3VFH84TpNwVlXWQ5WVG4Rv7LXZ AbOVffz9IcqDpV4qlWdm36jqrwLx5Flr1o+VFt0aRhSeFk0kVBZvK57tVM2nUIate9 AH6mvJiphww5q/EArHBI7Yr2LNZxT2jqj9nebTYO/PKgQ+a/ZjDrL3Zu3ChxRjYr+5 bPDCcOaZZqaV2jznUPnB1k9NooBw4EPMWr97ZoXy5i+PZOxP5Wm8TGL0bjtYMzH3wo 3w4tTP7E5+MWT35V2DNKh+1Lx6H/lB8Bbyf4a1tU13ogHyq4I+AYlLmRR6CA1e9GFu MC2hfzX/CF7hg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 25C7DCE00A7; Fri, 7 Jul 2023 21:56:46 -0700 (PDT) Date: Fri, 7 Jul 2023 21:56:46 -0700 From: "Paul E. McKenney" To: Z qiang 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: Reply-To: paulmck@kernel.org References: <20230704082615.7415-1-qiang.zhang1211@gmail.com> <77d16cbb-b28c-4b13-aecb-9ad787559557@paulmck-laptop> <087e3da2-ffd9-4cf4-8893-73f4edc3cfba@paulmck-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Sat, Jul 08, 2023 at 10:11:30AM +0800, Z qiang wrote: > > > > On Fri, Jul 07, 2023 at 06:28:29PM +0800, Z qiang wrote: > > > > > > > > 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? > > > > > > Hi, Paul > > > > > > I only find that for Preempt-RT kernel, the rcu_normal_after_boot is > > > set by default: > > > static int rcu_normal_after_boot = IS_ENABLED(CONFIG_PREEMPT_RT); > > > This affects only rcu but also srcu, this make the synchronize_srcu() and > > > synchronize_srcu_expedited() always fall back to __synchronize_srcu(ssp, true), > > > this means that call the srcu_might_be_idle() is meaningless. > > > > I do understand that the current setup favors default kernel builds at > > runtime by a few low-cost instructions, and that your change favors, > > as you say, kernels built for real-time, kernels built for certain types > > of HPC workloads, and all kernels during a small time during boot. > > > > My question is instead whether any of this makes a measureable difference > > at the system level. > > > > My guess is "no, not even close", but the way to convince me otherwise > > would be to actually run the workload and kernels on real hardware and > > provide measurements showing a statistically significant difference that > > the workload(s) in question care(s) about. > > > > So what can you show me? > > > > And srcu_might_be_idle() is not meaningless in that situation, just > > ignored completely. And that is in fact the nature and purpose of the > > C-language || operator. ;-) > > Agree with you :) > This make me want to ask another question, why srcu also use > rcupdate.rcu_normal and rcupdate.rcu_expedited to decide expedited > srcu grace-period or only use normal grace-period instead of > generating srcu_normal and srcu_expedited? Because I have not yet come across a situation where it was useful for the one to be expedited and the other normal. But if you know of such a situation, let's talk about it. Thanx, Paul > Thanks > Zqiang > > > > > Thanx, Paul > > > > > Thanks > > > Zqiang > > > > > > > > > > > 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 > > > > >