Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2287380iof; Wed, 8 Jun 2022 01:29:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiO8pFHVgC7+qu/83VJMc3DShZ06C6+/2vEi70MaJn5VYu8KWToILLufUWxhMSZ1M0mLsp X-Received: by 2002:a17:90b:3a8f:b0:1e8:7669:8a2f with SMTP id om15-20020a17090b3a8f00b001e876698a2fmr17954178pjb.55.1654676961709; Wed, 08 Jun 2022 01:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654676961; cv=none; d=google.com; s=arc-20160816; b=H/zAVuhEib7klDT4DZ+ORfFPW2Bw+7LBoJvT1uYjNs545rF6FRaPyzLyV1ruiU9L+X vMUC0LEI4BFtAEXCa/2hPw0fyqr/Z9WYOa9NcBSEdzQdMycTe89t7caAGCx04yE+LZJ3 BOM4BoiVOQ19LYwY3XTBOUbj59BfV8KBrrgp8a7UTw4K5eyhFVR1fECJP+C+7E5iT5sG b1fzNQTRZe8qVm+nlh3zpufJfKbhGD5b7qZ8GthvclnSDcLaH8TBEjQb8TCRqsMOoYaE gcklJYhcWoXw9wvI8JML2DBimS2lE57wb2grt7r4UBa10NCn1+417wkPSIZXQz0mnD+P nMzA== 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=yuKZiPANrn/2Af29yunkB7hhidbtlfIMOdjxWScANwE=; b=tofTq9+jNiy3i8WKK8BHRrQc3dYCVapR4mLYQ62onHgcMui2DLupNvafG60crU6eqs FqxfDKaPMiN2uUw0T67ezB8iUmwxMm8nJgaORrt8R6eOkyjYnI01uVUPI4gSwz6fLptc MBVOklR7R2tv3MIjQE6lWtZeq+lufj8cmNK2TSrF2Q2pBQJAT/0SLRAmIJDHm2zS1pZK GvZmNRyU6VewRhCYvi5IeOI0G1aLArLWmho8OO28ki2cCDyLfPH7pYuO+goggcGTCQb3 y7p+Y8GZB0MTrgBXJEYLnYStfzeoMzKRSklMFixYA/X1Dx/3ijvKFrIDeqajzv3ecwDi cTIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uYI4Evzt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e7-20020a656bc7000000b003fdf317f4a7si8214969pgw.427.2022.06.08.01.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:29:21 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uYI4Evzt; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 08E841E0C05; Wed, 8 Jun 2022 00:58:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235507AbiFHGDC (ORCPT + 99 others); Wed, 8 Jun 2022 02:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345327AbiFHF4r (ORCPT ); Wed, 8 Jun 2022 01:56:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06E631CB730; Tue, 7 Jun 2022 21:06:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 79246618F2; Wed, 8 Jun 2022 04:06:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA0C9C3411D; Wed, 8 Jun 2022 04:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654661187; bh=k2YvI5mx6ozTvjV13zYboBk4CqBDfNXpGFZG8ZqvpbI=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=uYI4EvztyHZFbqXpZuPM2C0hhE9dvRgbuhU6uz6AeXo2xt3cSTCXbwKjKI2/rfXmM bpn00cYcCQt40Jza9DZ403b2oWItNc2LQfFxnXn5QmT0g2TpAlvgAoAi1NEOqggrPb 18ZZhmHlDv/eBZFjF3rVkSEORP6NPsJ28u51lJ9hksUUoDdvpgIW+z5gCrKI+m5pzQ hhvl7WOEeeTzv3Q8z6AJkR8C8Qe0xhoWXnaSuhSvsLus0L7eJnXL5xTKS6/P1RLqF2 SaRo5JCZIkXt+ads4eup6kwBXFp5WtR2J8wxiEB5MlkYc+JkYZl3ubY0E7uo2AtZdf RLk09soiGuZNA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 5C2BC5C04B1; Tue, 7 Jun 2022 21:06:27 -0700 (PDT) Date: Tue, 7 Jun 2022 21:06:27 -0700 From: "Paul E. McKenney" To: "Zhang, Qiang1" Cc: "frederic@kernel.org" , "rcu@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] rcu/nocb: Avoid polling when myrdp->nocb_head_rdp list is empty Message-ID: <20220608040627.GL1790663@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220607075057.909070-1-qiang1.zhang@intel.com> <20220607161620.GH1790663@paulmck-ThinkPad-P17-Gen-1> <20220608005513.GK1790663@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 08, 2022 at 01:01:31AM +0000, Zhang, Qiang1 wrote: > On Wed, Jun 08, 2022 at 12:41:28AM +0000, Zhang, Qiang1 wrote: > > On Tue, Jun 07, 2022 at 03:50:57PM +0800, Zqiang wrote: > > > Currently, If the 'rcu_nocb_poll' bootargs is enable, all rcuog > > > kthreads enter polling mode. however, due to only insert CPU's rdp > > > which belong to rcu_nocb_mask to 'nocb_head_rdp' list or all CPU's > > > rdp served by rcuog kthread have been de-offloaded, these cause the > > > 'nocb_head_rdp' list served by rcuog kthread is empty, when the > > > 'nocb_head_rdp' is empty, the rcuog kthread in polling mode not > > > actually do anything. fix it by exiting polling mode when the > > > 'nocb_head_rdp'list is empty, otherwise entering polling mode. > > > > > > Signed-off-by: Zqiang > > > > > >This looks a bit more plausible, but what have you done to test this? > > > > Yes , I have only tested as follows and I added two trace events. > > > > + trace_rcu_nocb_wake(rcu_state.name, cpu, > > + TPS("EnterNoPoll")); > > > > rcu_wait(READ_ONCE(my_rdp->nocb_toggling_rdp)); > > + trace_rcu_nocb_wake(rcu_state.name, cpu, > > + TPS("ExitNoPoll")); > > > > runqemu kvm slirp nographic qemuparams="-m 2048 -smp 4" > > bootparams="rcu_nocbs=2,3 rcutree.dump_tree=1 rcu_nocb_poll > > rcutorture.nocbs_nthreads=4 rcutorture.test_boost=0" -d > > >To exercise your change, could you please also add an appropriate value for the rcutorture.nocbs_nthreads kernel boot parameter? Without that boot parameter, your kernel will not actually offload or deoffload any CPUs. > > I have set ' rcutorture.nocbs_nthreads=4 ' in bootargs. I see it now, apologies for my confusion! Thanx, Paul > >An alternative approach is to run rcutorture scenario TREE01. > > I will also use TREE01 for testing > > Thanks > Zqiang > > > > > Thanx, Paul > > > Thanks > > Zqiang > > > > > > > > Thanx, Paul > > > > > > --- > > > v1->v2: > > > Move rcu_nocb_poll flags check from rdp_offload_toggle() to > > > rcu_nocb_rdp_offload/deoffload(), avoid unnecessary setting of > > > rdp_gp->nocb_gp_sleep flags, because when rcu_nocb_poll is set the > > > rdp_gp->nocb_gp_sleep is not used. > > > > > > kernel/rcu/tree_nocb.h | 16 ++++++++++------ > > > 1 file changed, 10 insertions(+), 6 deletions(-) > > > > > > diff --git a/kernel/rcu/tree_nocb.h b/kernel/rcu/tree_nocb.h index > > > fa8e4f82e60c..2a52c9abc681 100644 > > > --- a/kernel/rcu/tree_nocb.h > > > +++ b/kernel/rcu/tree_nocb.h > > > @@ -698,10 +698,14 @@ static void nocb_gp_wait(struct rcu_data *my_rdp) > > > TPS("WakeBypassIsDeferred")); > > > } > > > if (rcu_nocb_poll) { > > > - /* Polling, so trace if first poll in the series. */ > > > - if (gotcbs) > > > - trace_rcu_nocb_wake(rcu_state.name, cpu, TPS("Poll")); > > > - schedule_timeout_idle(1); > > > + if (list_empty(&my_rdp->nocb_head_rdp)) { > > > + rcu_wait(READ_ONCE(my_rdp->nocb_toggling_rdp)); > > > + } else { > > > + /* Polling, so trace if first poll in the series. */ > > > + if (gotcbs) > > > + trace_rcu_nocb_wake(rcu_state.name, cpu, TPS("Poll")); > > > + schedule_timeout_idle(1); > > > + } > > > } else if (!needwait_gp) { > > > /* Wait for callbacks to appear. */ > > > trace_rcu_nocb_wake(rcu_state.name, cpu, TPS("Sleep")); @@ > > > -1030,7 > > > +1034,7 @@ static long rcu_nocb_rdp_deoffload(void *arg) > > > > > > mutex_lock(&rdp_gp->nocb_gp_kthread_mutex); > > > if (rdp_gp->nocb_gp_kthread) { > > > - if (wake_gp) > > > + if (wake_gp || rcu_nocb_poll) > > > wake_up_process(rdp_gp->nocb_gp_kthread); > > > > > > /* > > > @@ -1152,7 +1156,7 @@ static long rcu_nocb_rdp_offload(void *arg) > > > * rcu_nocb_unlock() rcu_nocb_unlock() > > > */ > > > wake_gp = rdp_offload_toggle(rdp, true, flags); > > > - if (wake_gp) > > > + if (wake_gp || rcu_nocb_poll) > > > wake_up_process(rdp_gp->nocb_gp_kthread); > > > swait_event_exclusive(rdp->nocb_state_wq, > > > rcu_segcblist_test_flags(cblist, SEGCBLIST_KTHREAD_CB) && > > > -- > > > 2.25.1 > > >