Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp55374lqs; Mon, 4 Mar 2024 14:56:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXptDWWoqCd+1ZU8lpreC6e3Oedzvz6pL9BBEcJCOOi+7iBNnsZwVAJOkw0000Dpnc+3HpGAg9olisLNpMRHw3RCR7cPpmtJImA6pXo0g== X-Google-Smtp-Source: AGHT+IGqWrEGoNqEOvCeISakffpcoGHKxXHEStXJsbWkBfFrPE1T/cmC1qLcIJ1e1mXRTftz5NUT X-Received: by 2002:a05:6512:219:b0:513:2caf:15ee with SMTP id a25-20020a056512021900b005132caf15eemr101552lfo.28.1709592991783; Mon, 04 Mar 2024 14:56:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709592991; cv=pass; d=google.com; s=arc-20160816; b=RmP8fXRTT+9pxBElCXpndgH1DixyDT6MsPE9G652AXf+zCfQMfPnad+o0fRGzYTwL4 AmNkf6kcpicDL9r0d9acKg/dZ99yWI2PEGyz+ib+oSUMuLfnlbhDULb/SD9HKg3UG3YV N5JPAswsAG/FiRjJgLtpZKvA1ooVy2Krh1Sv+I+LDxohwvK7Sk253nOZbkBWupM+Pbiu 5zhEx7O99ecB8xflG9NoXR5DlEJHpIxicgeXUB8XkrIApc3dWtkKXeIqlLSJ/BKHQgF8 J/yBF9xO942zBsFpISeKwVgP+5mIeJBZ78aLw0nvfVdNgSOf5u9gOTaVwysTYB2tMy1W jR6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OCNhyKtCXmXnXtZs4R8HFZYMLv1UzRhfyrQGZFJlidU=; fh=x5EVJoPG6ig7lfovOxVsbUIGy7PuVoTFc209eBD3IO8=; b=lsHPbeZcKL73WRJPCXsnO/UB13THUUy4wk04WDWVYryNlMK1Q3yREnHidUem27yULY Y0O0z9n96h70bl9B5H4vI4oBYmtiyYOsHuRsOvcnJQhlWLXlQN/QvHNj1TOkBCvoaUhz bFyXF90FvMY+x+TOU+t9Tkn+UTQnx5mtaZFwFumQI6y6rnqUlJ8T2ncvRiGjV2dKeQ/w fXD2KAwmWb/8lchBV8ThKJl7TvuaodwKHRIezppuxm6I3WeaVHl63u3nhwCC6n/rAak/ Z3Cp3/UVRAhi7YbWaiEMQgb0L71jdqc0IGEDUElnCSGnSygz5lueSBsP6fO1HZThkhRz O3uw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=idzNyh1w; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-91385-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91385-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t14-20020a170906178e00b00a3e5ad050a5si4413081eje.983.2024.03.04.14.56.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 14:56:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91385-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=idzNyh1w; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-91385-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91385-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 71E8A1F22280 for ; Mon, 4 Mar 2024 22:56:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BAEE17C0A1; Mon, 4 Mar 2024 22:56:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="idzNyh1w" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE25A7B3FA; Mon, 4 Mar 2024 22:56:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709592983; cv=none; b=HRgNmaIJwSLdhGdHVQ+QgGcHHC9NVcHXGHG1VgCEoVSNql/KdvkEaQNr03YQ5CzO83Cz20+RFgAakkIcfqVuxx+tpwTkIsyK3yWNBAU5VnCOWn+vCj4qjjAvMCcV7/8S7F58zHkjr+xkBOTuKQ9/8La1MakEreiGXsskewtmQqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709592983; c=relaxed/simple; bh=Rca8aMJHIqobe+2cMX0r2HJ1hKWMth39li8Jrzh0q+Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=IdevH/pcmOR+PLvLsAx5ku9H3E+2pr6zfUsrlIdpv2nxaN03oWYizj+vqtUTQTyX2QED+pWxcS9PPQxPt0M1/u+HwfkM/Bp9jkALVBaAO6hlijqLIR8kqEkzTkw2ngRIas5Qww3PXaQiKUNWwWSVrDa5THVoIZPQ3DPLZrRKFPg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=idzNyh1w; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0A81C433C7; Mon, 4 Mar 2024 22:56:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709592982; bh=Rca8aMJHIqobe+2cMX0r2HJ1hKWMth39li8Jrzh0q+Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=idzNyh1wbBFfPcAk+olSqkNX1veouQGtHnwbiW37ZtHp/r8KVR+WdaRL7YdT189KC BhTyV7818bJg4H2CuIRcu39XeBNhDi41dbkyvWF/vPaA1ZeRyldnykaAjNPNXmmNEX vAtViu02BG271a9Rf8zBWnrTyeV6/lsqUYfPT42bDr9pl98/TZ5I9FglR4R8yca76r 8XLdmujf7FB5L/fF8uh1DPtY+ZBnvMFp4m5lhsMTdSHBPyiWN1mUKp2g4EJ6PRurhh RKUlOF63h6Sxx+fcfQ/iZYBypoXuF77PpO80F68zOXB+TP+bTas7po3FC1JrcXmAa+ itVaciyyOGvGw== Date: Mon, 4 Mar 2024 23:56:19 +0100 From: Frederic Weisbecker To: Uladzislau Rezki Cc: "Paul E . McKenney" , RCU , Neeraj upadhyay , Boqun Feng , Hillf Danton , Joel Fernandes , LKML , Oleksiy Avramchenko Subject: Re: [PATCH v5 2/4] rcu: Reduce synchronize_rcu() latency Message-ID: References: <20240220183115.74124-1-urezki@gmail.com> <20240220183115.74124-3-urezki@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Le Mon, Mar 04, 2024 at 05:23:13PM +0100, Uladzislau Rezki a ?crit : > On Mon, Mar 04, 2024 at 12:55:47PM +0100, Frederic Weisbecker wrote: > The easiest way is to drop the patch. To address it we can go with: > > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > index 31f3a61f9c38..9aa2cd46583e 100644 > --- a/kernel/rcu/tree.c > +++ b/kernel/rcu/tree.c > @@ -1661,16 +1661,8 @@ static void rcu_sr_normal_gp_cleanup(void) > * wait-head is released if last. The worker is not kicked. > */ > llist_for_each_safe(rcu, next, wait_tail->next) { > - if (rcu_sr_is_wait_head(rcu)) { > - if (!rcu->next) { > - rcu_sr_put_wait_head(rcu); > - wait_tail->next = NULL; > - } else { > - wait_tail->next = rcu; > - } > - > + if (rcu_sr_is_wait_head(rcu)) > break; > - } > > rcu_sr_normal_complete(rcu); > // It can be last, update a next on this step. > > > i.e. the process of users from GP is still there. The work is triggered > to perform a final complete(if there are users) + releasing wait-heads > so we do not race anymore. It's worth mentioning that this doesn't avoid scheduling the workqueue. Except perhaps for the very first time rcu_sr_normal_gp_cleanup() is called, the workqueue will always have to be scheduled at least in order to release the wait_tail of the previous rcu_sr_normal_gp_cleanup() call. But indeed you keep the optimization that performs the completions themselves synchronously from the GP kthread if there aren't too many of them (which probably is the case most of the time). > I am OK with both cases. Dropping the patch will make it more simple > for sure. I am ok with both cases as well :-) You choose. But note that the time spent doing the completions from the GP kthread may come at the expense of delaying the start of the next grace period, on which further synchronous RCU calls may in turn depend on... Thanks. > > -- > Uladzislau Rezki > >