Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp55470rdb; Mon, 4 Dec 2023 20:27:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/FtI2G0cl11I3/OZHi1sBdf250FUZVHhlPDLawgofwzY2aTZY0dHtO9BkXZZEl13nTXtT X-Received: by 2002:a05:6870:548a:b0:1fa:f56e:e9c with SMTP id f10-20020a056870548a00b001faf56e0e9cmr6195031oan.3.1701750432388; Mon, 04 Dec 2023 20:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701750432; cv=none; d=google.com; s=arc-20160816; b=WSuP2AzNQmq/IfFTdQp8Xq0tN9xjdLVIee5DxNLhbFrt4ldYIb3PfXGsOiuc0nxVCL pu9ej0zZXwZO2kY0y6SPU2+PddXpXW01G4IP1QDx9YHeHUs61JW0XgWm+/aY7ab292hl ODXiG3+6896A1YCcbSzrsa+8s9GMdtnhvldbd4ajmx493a+c6pVEp683Tj97ynw3nIuF w5M+R03kRD/SQTukYLcAqMEtI1ImzqLRXz4pU6m+8sG32B14pKmvklGB70ddiKP2YWaD RIWpKuIWB/4McxCIkOMit16vDbPyCengBBaeXwXqE6OmfJFJAFk9Z6wJfWCIW5EMxO2j 2N4g== 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=D5Dii3KniojaMabhJUoVUBaGuqY+ppI+2gh4Up22JX0=; fh=OFmzAtGuV71IRqzddT841E2d1DlXaeMt13vIC8KSzLk=; b=GQcOMC8QMnhWaujunUskS6xikACZe+ZA3e5UzPyIEgbDhseRfNCswuf5IsgZI94Tn3 p1jxW1iXsB+NJAZUfVRM5NNAgIfR2nr8eTuAw3o5Su3e88hboX7icWsschlbZjPgmy0Y XspODEJM+uoV2UX48xkMyq4zE35LC70duD3WFB2IeqV7/J8Vs0vP3xRgKpR85D45J1ly 4yJVxrHXjtzJSCwH7tzJXWLdT/XAdhIDf4y7t2oSNnspb8JRIcEknIBTzESga6PLf54N cppQ1Au6jyvS8vySw6eV1zBHTkV18ezVmZde02toUppHV5NOgvwDg4eLVPS7xJ8W/+d+ F/JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hjtRZy08; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z27-20020a630a5b000000b005bdf5961646si8712887pgk.268.2023.12.04.20.27.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 20:27:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hjtRZy08; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7124A804595F; Mon, 4 Dec 2023 20:27:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344103AbjLEE07 (ORCPT + 99 others); Mon, 4 Dec 2023 23:26:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231417AbjLEE07 (ORCPT ); Mon, 4 Dec 2023 23:26:59 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 979CD9C for ; Mon, 4 Dec 2023 20:27:05 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DD44C433C8; Tue, 5 Dec 2023 04:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701750425; bh=Etgekf0ZrWRy/UX6kYpcWzxJxhTWLWEmZUQoTp7t7+0=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=hjtRZy08etGTrct5yZFp18b0ITpG0KrAxWOHT1LHT7ewS8IvwgRdYE3878TSwokib TXjGWublmQAqEbQl4ASY+Czp4rfXt02To7MKM2XaqVh0pmTrxlB+hoL1H9QA3iB2l5 brvvVHYA9dv83u/Saf6s6ZKYrKPj/o8LKGgxqnSRGM6Sa58iZOie+owjcNLEP7dtvh HEHY2ml2saQPp6zK7jdHISQ8zb9q62+TQaqv8UpMe3cWAvwXnYAGcxeOChwyTqwhcU busNVg1+AzOt7Tg0MQvy+cSIHJxZDRSO71Eji6d3RE8Izr57VRvL57N0NcMG8daH5f IK7H5S3fGzrVA== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id B4DE4CE1147; Mon, 4 Dec 2023 20:27:04 -0800 (PST) Date: Mon, 4 Dec 2023 20:27:04 -0800 From: "Paul E. McKenney" To: Andrea Righi Cc: Qais Yousef , Joel Fernandes , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , John Stultz , linux-kernel@vger.kernel.org, rcu@vger.kernel.org Subject: Re: [PATCH v2] rcu: Provide a boot time parameter to control lazy RCU Message-ID: Reply-To: paulmck@kernel.org References: <20231203011252.233748-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 20:27:11 -0800 (PST) On Sun, Dec 03, 2023 at 02:18:19PM +0100, Andrea Righi wrote: > On Sun, Dec 03, 2023 at 01:12:52AM +0000, Qais Yousef wrote: > > To allow more flexible arrangements while still provide a single kernel > > for distros, provide a boot time parameter to enable/disable lazy RCU. > > > > Specify: > > > > rcutree.enable_rcu_lazy=[y|1|n|0] > > > > Which also requires > > > > rcu_nocbs=all > > > > at boot time to enable/disable lazy RCU. > > > > To disable it by default at build time when CONFIG_RCU_LAZY=y, the new > > CONFIG_RCU_LAZY_DEFAULT_OFF can be used. > > > > Signed-off-by: Qais Yousef (Google) > > Thanks! Everything looks good to me and I also verified that > rcutree.enable_rcu_lazy is enforcing the proper behavior. > > FWIW: > > Tested-by: Andrea Righi Queued for v6.9 and further testing and review, thank you! Thanx, Paul > > --- > > > > Changes since v1: > > > > * Use module_param() instead of module_param_cb() > > * Add new CONFIG_RCU_LAZY_DEFAULT_OFF to force default off. > > * Remove unnecessary READ_ONCE() > > > > Tested on qemu only this time with various config/boot configuration to ensure > > expected values are in sysfs. > > > > Did a bunch of build tests against various configs/archs. > > > > Documentation/admin-guide/kernel-parameters.txt | 5 +++++ > > kernel/rcu/Kconfig | 13 +++++++++++++ > > kernel/rcu/tree.c | 7 ++++++- > > 3 files changed, 24 insertions(+), 1 deletion(-) > > > > diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt > > index 65731b060e3f..2f0386a12aa7 100644 > > --- a/Documentation/admin-guide/kernel-parameters.txt > > +++ b/Documentation/admin-guide/kernel-parameters.txt > > @@ -5021,6 +5021,11 @@ > > this kernel boot parameter, forcibly setting it > > to zero. > > > > + rcutree.enable_rcu_lazy= [KNL] > > + To save power, batch RCU callbacks and flush after > > + delay, memory pressure or callback list growing too > > + big. > > + > > rcuscale.gp_async= [KNL] > > Measure performance of asynchronous > > grace-period primitives such as call_rcu(). > > diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig > > index bdd7eadb33d8..e7d2dd267593 100644 > > --- a/kernel/rcu/Kconfig > > +++ b/kernel/rcu/Kconfig > > @@ -314,6 +314,19 @@ config RCU_LAZY > > To save power, batch RCU callbacks and flush after delay, memory > > pressure, or callback list growing too big. > > > > + Requires rcu_nocbs=all to be set. > > + > > + Use rcutree.enable_rcu_lazy=0 to turn it off at boot time. > > + > > +config RCU_LAZY_DEFAULT_OFF > > + bool "Turn RCU lazy invocation off by default" > > + depends on RCU_LAZY > > + default n > > + help > > + Allows building the kernel with CONFIG_RCU_LAZY=y yet keep it default > > + off. Boot time param rcutree.enable_rcu_lazy=1 can be used to switch > > + it back on. > > + > > config RCU_DOUBLE_CHECK_CB_TIME > > bool "RCU callback-batch backup time check" > > depends on RCU_EXPERT > > diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c > > index 3ac3c846105f..8b7675624815 100644 > > --- a/kernel/rcu/tree.c > > +++ b/kernel/rcu/tree.c > > @@ -2719,6 +2719,9 @@ __call_rcu_common(struct rcu_head *head, rcu_callback_t func, bool lazy_in) > > } > > > > #ifdef CONFIG_RCU_LAZY > > +static bool enable_rcu_lazy __read_mostly = !IS_ENABLED(CONFIG_RCU_LAZY_DEFAULT_OFF); > > +module_param(enable_rcu_lazy, bool, 0444); > > + > > /** > > * call_rcu_hurry() - Queue RCU callback for invocation after grace period, and > > * flush all lazy callbacks (including the new one) to the main ->cblist while > > @@ -2744,6 +2747,8 @@ void call_rcu_hurry(struct rcu_head *head, rcu_callback_t func) > > __call_rcu_common(head, func, false); > > } > > EXPORT_SYMBOL_GPL(call_rcu_hurry); > > +#else > > +#define enable_rcu_lazy false > > #endif > > > > /** > > @@ -2792,7 +2797,7 @@ EXPORT_SYMBOL_GPL(call_rcu_hurry); > > */ > > void call_rcu(struct rcu_head *head, rcu_callback_t func) > > { > > - __call_rcu_common(head, func, IS_ENABLED(CONFIG_RCU_LAZY)); > > + __call_rcu_common(head, func, enable_rcu_lazy); > > } > > EXPORT_SYMBOL_GPL(call_rcu); > > > > -- > > 2.34.1