Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp333965lqs; Tue, 5 Mar 2024 03:36:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWSamAU4Xzso40AoPO+4oE2SDdYl1edLkeAeqvKjNnKAz/8YLGUFXCsEfhtB8XxtjGzlk/L0Wmw3GrlLgnRB6om4HwU0LsBcYjzgFElPw== X-Google-Smtp-Source: AGHT+IGGX9EcplLmwN83jOakNOXc9YcvStjPvagPL8IPnZsSyT+bjQsI/zOzXP+qszAk1YFfugqW X-Received: by 2002:a05:620a:8c05:b0:788:399a:3ae7 with SMTP id qz5-20020a05620a8c0500b00788399a3ae7mr284950qkn.8.1709638599335; Tue, 05 Mar 2024 03:36:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709638599; cv=pass; d=google.com; s=arc-20160816; b=t1MiYm7Uh5F/BPsAUvRPythoptwGX37lpxnucH8/9nLt0zvl4Gq33kCWO/hj206Qxo aVNVsiNrFynkmGMgqXsOOXMOvcAR+mraZNdmeYRFQtBtCXs4zBNWBkiGdRgOLAiDErJc kN6zrGTPSKhTA8zcUcJ0SCfpINsTboxlCLtxlfhGw/TueJR5A+aswE2QCxxaPFvaS6Ff YEPZxw1668r+ZhGpe9Dop3cLVk8hewZpSfbC2u4o+f4i8U2iVZ1gcBz1fiZzMnmI9PwH BWr1emiOYg/ui1GROqLi40M1jyu8Ph/QGd+lm8judml3lhO+wgCXoZ0ACpLgGaz+fki3 HxGw== 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=MlYQT+NqlsHH1pLyRuEw9g7sEKjqaGbpTx/q3OYgo7Q=; fh=x5EVJoPG6ig7lfovOxVsbUIGy7PuVoTFc209eBD3IO8=; b=EL7UYHJWT4hYAbA120NatUY4Zz98uBjAPT0TfhFYDEuUf4eK4FvBnG5bNQUT+umjar 6YxgILwolBRDJ0//ROB/Poj/v3BkBqEp+HIZHpOOdGq+Wm4OlQtmjz4ES/ivQ3sUrvhF eL3kc36ztfMgB+TJd5hdbbIk1imBj4ptwF4vygo6rq2oYgS5Fi6n84bsupVfXc2I1Q95 qvy7tgWjuwlTzIbTX/CcUvhsASmt2oRhgQ+fPPS8NMXUoTh9sePKo6eenmSnGnE+zeIg HCquX2+aslLkhDm8gzUsv+U+AxcXXaPMLKg0k9rt7AjbsBrGezpUCxIpqiN5GuH6BBtf STKw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XI6XFNSQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-92294-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g12-20020a05620a278c00b0078836f1e0e9si830593qkp.760.2024.03.05.03.36.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 03:36:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92294-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XI6XFNSQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-92294-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92294-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 16F4B1C22383 for ; Tue, 5 Mar 2024 11:36:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0768957326; Tue, 5 Mar 2024 11:36:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XI6XFNSQ" 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 31BCA1B94A; Tue, 5 Mar 2024 11:36:32 +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=1709638592; cv=none; b=qtP4Ql0eTHAEcmLx6XJyfgTKVZoYi8eHXqkER0K6KMJSemzlSzb49zDJ/EzHQ7lRgviZwda4UnwyoJIoAB+rQjP5rdMF1eryqBL9G8H0XJWYGg60IfkygHiDRy9nb/cavK/veqMEALVjC4hOomqXWMVV4oboB0GpcGB6/dDCvpY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709638592; c=relaxed/simple; bh=vwD3BWS6M42qq7XJEJgBmFdf8+GmcvadJcolAH9VwJU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NKM9sFFBUoDpIo2/zgNHT5ilTIk1YZINYG1q50tInbjHTQS2jEVsNUfh1TKHJoCp7bkOm2fg1cMBI6sQPF8Im2CNBdkc9hlCzBPdpQ2+3agbpM31OSLSdz1BMJ0M6M7qoWfO0JJ1Meo00k1V5plNIlPUQzAnvMrQQpiiV3ycV24= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XI6XFNSQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8CF3C433F1; Tue, 5 Mar 2024 11:36:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709638592; bh=vwD3BWS6M42qq7XJEJgBmFdf8+GmcvadJcolAH9VwJU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XI6XFNSQgy+QLFvQeLImHR/yYJBq04ff3Okkuw30/56lD0lUitjo8M4QJzROS+8eb ZDOvAp0DRIJz9I4FsZjKH95hyV/tHApIKs6qFo69ODQvRDm4K69WzCEh0bImM7zcVA NPGW7yC9O7owkoXAyxveQgvbPAOU7eZ0PXOBImnVTvuG/rnCoHoDImX7HKfXfa1YbD uXAIXLVVlYRGIz447OVoif9nGttoEg1D/oEv+q5s65wMksYO0J5jVKT2VrOmMPfQj4 tLl4SMQ/s95Ony0r2/KWfmkwCp/FYvHcXg0UcE9dvuRyMPkHOQYVxyCmLvSQsVlYV6 V4iS/LEOkBY2A== Date: Tue, 5 Mar 2024 12:36:29 +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: On Tue, Mar 05, 2024 at 10:38:00AM +0100, Uladzislau Rezki wrote: > On Mon, Mar 04, 2024 at 11:56:19PM +0100, Frederic Weisbecker wrote: > > 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. > > > No, it does not avoid for sure :) I will add more explanation. > > > 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... > > > That is a true point. Therefore we do it with a fixed number which should not > influence on a GP. Sounds good!