Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2149982iof; Tue, 7 Jun 2022 21:25:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywZz9OAyUbWZiJoT05Mb0mrniZr6QeopRv6StkGwfvdh/UORKlK4AThL93gvck9xKrYI9J X-Received: by 2002:aa7:9475:0:b0:51b:e0c5:401a with SMTP id t21-20020aa79475000000b0051be0c5401amr25962090pfq.39.1654662302891; Tue, 07 Jun 2022 21:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662302; cv=none; d=google.com; s=arc-20160816; b=WbprT2waO127As8+kD4Sfl6heC8aCwLtIhA66R4STcUeXnmYjBK4rA84oi4aVXgFGa bcuUJRcNRi3WTirnIHOR8njQQhiau1MYYZF+7b+O7oBXSXARVm7VdgBujJZDeVS7rG9P 21eui1+MKRgcPfbXVct1oK6Lip66YOFfeo/FATrgRoyYdBS19ogNrEEXYdqymH4xYHKL CAMfmPUDVPUbzpptHEpA5+aETCdEsTmD2gKuWafu43ey/7X8SJ3xP8eXwDzzQJxyFk0i ISlwA5eyzKWgBFa2NxysjLrRbN5L/bUo+DPQjM9mAnkjtsrAhAWhALAo4dQVjxRRMJw5 oB9w== 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=QwWgeO6Nvc3mk1GrAf2xo2+gBBzgoWtUp8e+LGs1nVI=; b=SKg8yfkb04WuwPvhJ1wd4qHt6bhKJvL6nUIc+Eynq78mi8Ze8s0Is67Fg88AxfXIaF NjgXkeQSx9xtBWQeekY/BQXctccyg/3aNNV63u+jBICWx/YmgytyiSfVJRhaXD9LEgjN Dn62adguI4tzFPKSYbVSE/5QPcYonE1COpkLDMxoPbqbJsowqP1W7szZrFRg1356v+bj c08ldvGegoVRjhU7CyFApQw9SiulmVc9qb54gM5M80gDN1x8FJZNTf43AEDID9ZkvNLI U1ibgthy4EwoAiw6m/YR1GbC4EnlbLcIxMAnyE93v92NpjBRaTOly/nLLOwPIhjisxPO KN1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UIV3IEAA; 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 k18-20020a63d852000000b003f9dd67d2b7si27108991pgj.34.2022.06.07.21.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:25:02 -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=UIV3IEAA; 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 DDE8043C4E2; Tue, 7 Jun 2022 21:10:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344804AbiFGQQj (ORCPT + 99 others); Tue, 7 Jun 2022 12:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344914AbiFGQQg (ORCPT ); Tue, 7 Jun 2022 12:16:36 -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 28BA1100536; Tue, 7 Jun 2022 09:16:22 -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 B56FA617CC; Tue, 7 Jun 2022 16:16:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12E1DC385A5; Tue, 7 Jun 2022 16:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654618581; bh=pZ0N3kVmID+M42htHeCDWI/UBkUn4DOHwjZbPNx736A=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=UIV3IEAAq9umOzgHxHRMDm+JQ9rRW/rCgMfjUe4JFKLAGLG1mWx0oAy5xuTqa8N9D ZMHZm+aa9W7dcOvRKVm74Sy/6yMuijoKJcbx6braoXJA0F1mjIdTfXRm/ECj/B+8B+ zURMMpv2iihqCjWcP2e+TnOBgSA+stsXWEnUcfpOxe8RnRd7BRHp5I8PTPA34hioht EHdBW+qyWxAjbOyQX12NK23TnE/0V4nKE2+qL0G3nqpgoEgQ/JvSC5ZZdF7qbt6QYI qqGkHJDFLc73S52n3GBgNVdtoMuef+AcsJprU0+s15SvRgrBtDQk1gp3c3kMfjrOy0 v5LwwExSsHVTg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id ADB205C05DA; Tue, 7 Jun 2022 09:16:20 -0700 (PDT) Date: Tue, 7 Jun 2022 09:16:20 -0700 From: "Paul E. McKenney" To: Zqiang 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: <20220607161620.GH1790663@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20220607075057.909070-1-qiang1.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220607075057.909070-1-qiang1.zhang@intel.com> 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 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? 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 >