Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2257358iof; Wed, 8 Jun 2022 00:38:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0rKuU+B75+wHgsQdTVI3muC/QowgINhgk2deCluU3zQkHnWyO26EGyKIhZXgPvbMKS8k5 X-Received: by 2002:a65:6c07:0:b0:3f2:5efb:6c7 with SMTP id y7-20020a656c07000000b003f25efb06c7mr29177290pgu.496.1654673906810; Wed, 08 Jun 2022 00:38:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654673906; cv=none; d=google.com; s=arc-20160816; b=KunM63b0agnegnRcwunr2Tb72s7l+7JYOCUox5xM0yioqiqKugZf1j4tATOHmFOrE4 WByWXUS4FVQrJ5DwN/KlydteN7FPrQI/6G5/OdwXCq7mHl0XRetQ8QkbNmOj+x3Mw/3S K8B+rfxb6pJTT08q/vxZ2TbF1JEcF6RseJZWnfjIZsfI2ELr8yAA1opVjZZ9r8rA6Zbh 1AjDBMGDykX2V+ylg5A1F1+a0d161xwSA9Rg7mh3IGgAcCJP1RiikixBfLhdUM6SX1Rt InL6I3EitK2NLSdvrxAx1fi6b8tnM4d4AWJu1ZnleiCJPXXTtzZWOHm4JEVQH0Yno0d5 qXFg== 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=cf4yiXA09zKy73LFkPv0my8I9NTpoMlcXqLnBsoFSIM=; b=lNNanfoznYD5Iwhg/frxD/axbuL+h/PZ76KP+YrKeECD4p8+biZMqaaplCjRx97Gd5 cNElFeCaVwlIU8A1whZMDgST+z+OyiJsbTHcOs3OOrsDm1NZaNUHz9nwXiZVqBTNDr/P fYXktqZYHnm2ojeneb1RdtGTf6XSFtIVcGVzv2l9lE7fL4R/dQ/AAjttIbrBdA1DjpMb HiNiw/dY8J4xbaz8gPOQUOxfekPmMJ7MYbJWGOzncEHaxPSCMCFzzIwhgjAHeHTiu4Ly NC77iAH/L60wsUvhM2tf4ep9JSMRN7XOJ2RpWuVhSPm3Y/mhjbWuCEhSw5L2CGXg6Kkd hKQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NHoVYZTn; 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 x26-20020a656aba000000b003fe34317ce3si2191176pgu.761.2022.06.08.00.38.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 00:38:26 -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=NHoVYZTn; 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 9198026B953; Wed, 8 Jun 2022 00:08:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232149AbiFHDrT (ORCPT + 99 others); Tue, 7 Jun 2022 23:47:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234021AbiFHDpF (ORCPT ); Tue, 7 Jun 2022 23:45:05 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFC3922C834; Tue, 7 Jun 2022 17:55:19 -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 sin.source.kernel.org (Postfix) with ESMTPS id 01557CE2519; Wed, 8 Jun 2022 00:55:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 046A7C3411C; Wed, 8 Jun 2022 00:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654649714; bh=xjrzCsFcTkudeoY/nGuX8OacXikEuO8+6CAFVuglQwI=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=NHoVYZTn6JJtZuWt1ytsYScgxa49s3JFPBQwXYh8/atVWV9fk89xE3ptxILwu6Gxo 50JlDiPwWRBX7/Hrw6tqpksPvGquDaOL8NC1x3SVo1TNmu4EkcPguSLNkZXF5qW8C6 TfiKLoWXWQxmvOoKGPlA1vvsBSFSm4US4VuEc5sjsRelt3k6mZYyiw7Xhef/sw3ez5 UX4sNJZTejhB7XIahuth09pXmVs3+jusrOvffPa1psn9Q9IM2YjE+UtErAiSWpumzN hKNh9HJ56MKQv6N1chDcFZ0XkUeOKaeu88LRn+DgTRIWyXLwtt0HWBCKb/mTFTncMr x8r6oJiSl/RrQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 8C2AC5C034F; Tue, 7 Jun 2022 17:55:13 -0700 (PDT) Date: Tue, 7 Jun 2022 17:55:13 -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: <20220608005513.GK1790663@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> 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 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. An alternative approach is to run rcutorture scenario TREE01. 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 > >