Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2121427iof; Tue, 7 Jun 2022 20:26:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLa8VxazfR5nSzSUGTrCDOKuaYKpLDeUJm+BEl6vZbtxiVo5nnjtfOR8Hd58VTJf1+ImBo X-Received: by 2002:a17:902:f7cf:b0:165:13ac:cac8 with SMTP id h15-20020a170902f7cf00b0016513accac8mr32825284plw.20.1654658811573; Tue, 07 Jun 2022 20:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654658811; cv=none; d=google.com; s=arc-20160816; b=T8hkmLXDRcWPbn/7+UcH8TL23rd4/5PmKQFWdTTEqBGMPo1mOD8/KZmRKXCzk6vGLg o3feip5TvyzgdAFphy5XTNVUUK7rw5b5723ODAUDtDIwaTOasrqflPQzvkFt4NSGQnQU rSTOLM8o5ADbI21bOyr8yfp/Fp7xqi0MYvUyl1k55mt9yoIPRe5G6w9V5Uxf2cvUNKv0 w2senFFVVcGaz2S7r6vfBIxx1hRweav6sGtxeyUwqgeCeCnuBVd0o2NlePJaARRC4aF2 Dv2KotuGrEucmba9r0ENCp2dLLoJflPs9IpP/jyAIvaDWyj1Jf6vILSFhoJzjAXNBVfL pNvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hucqvCKHyVXNMXJ6/WB+2RZZ5yfWIEPmBrywcdM9JnY=; b=RyDStvg8y/AqHj7udWdjTMLR6pQzDq2yCpVO8QSB33IKLBHOIny+orT032iGSfZRFW rlXC8+8U9ng+eSDMY3fm/k+OyhFCzFPdxGMzJ6MZyY0GskEZ5JXZR14ugSIezW+cmJ2O BWg1s6OJxb59mURoaaREF8pKr7d/CQ+ixd+BT9WQexvVfKVI1LslY/yHNwCncABERpYL bWlNuMPG0SxaeGIZd0zncYb75YHvupzzKdVQxaeqp44ZEyv5AbWMNgEe7yx6t0Unjpdg lVnxiCTmI9OxXW5a+uhl/Ixv9tuPr6B5Xk4MJo7xDXl5TvcwMHIOL0Z4NV8ZWWP2tPEj 8lgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GiLLI+04; 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=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id s6-20020a056a0008c600b0051bb0daae82si29367871pfu.377.2022.06.07.20.26.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 20:26:51 -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=@intel.com header.s=Intel header.b=GiLLI+04; 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=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9F4CD198C14; Tue, 7 Jun 2022 19:48:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbiFGHvO (ORCPT + 99 others); Tue, 7 Jun 2022 03:51:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbiFGHvM (ORCPT ); Tue, 7 Jun 2022 03:51:12 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ADE6C9664; Tue, 7 Jun 2022 00:51:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654588270; x=1686124270; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=uK91ZcW1W7x+yvwxlB6uEa0V46hkzdc1gVduu3AMBJA=; b=GiLLI+0492aCiXaGYLkvYFSzIvGspTrsSwNeu3a+wsCL+5BRcaK349uu fzsCBBFgKck6Kt/44nB+cSBQU5JDSWadz/yMvaT17eDiWogXfnx7pBuF2 CPxVBXGhvfUS7ipTG7t2qKmXbq2rTuXX2Gm1F7nBmCL5ec+eg/fBfSKLd p3M8hVOECBuE5yw6aNkATQTksMCZfZjJjbPKdrmc876d5ekQamTpXlXSV Zc5njEU6PF3vUNbK8kFwy8EySqqd29XhgQ1KMLq0UHHm96jgom01AuhLu /ItMgy+4LmlZomNq7DI99KIPVyrJYUn5sP9FrZ23WpOz95Rqt/wb9Uyrs g==; X-IronPort-AV: E=McAfee;i="6400,9594,10370"; a="363054959" X-IronPort-AV: E=Sophos;i="5.91,283,1647327600"; d="scan'208";a="363054959" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 00:51:09 -0700 X-IronPort-AV: E=Sophos;i="5.91,283,1647327600"; d="scan'208";a="636008143" Received: from zq-optiplex-7090.bj.intel.com ([10.238.156.125]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Jun 2022 00:51:08 -0700 From: Zqiang To: paulmck@kernel.org, frederic@kernel.org Cc: rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] rcu/nocb: Avoid polling when myrdp->nocb_head_rdp list is empty Date: Tue, 7 Jun 2022 15:50:57 +0800 Message-Id: <20220607075057.909070-1-qiang1.zhang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, 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 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 --- 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