Message ID | 20231203011252.233748-1-qyousef@layalina.io |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2028410vqy; Sat, 2 Dec 2023 17:17:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IES9ahcYsfekFfGDpbZlm2/qJ0O7t0TTzFNvaJEuliJkzFTaOa83TKR6cSoNCMm5waJQAex X-Received: by 2002:a05:6e02:101:b0:35d:59a2:1280 with SMTP id t1-20020a056e02010100b0035d59a21280mr2540768ilm.44.1701566258351; Sat, 02 Dec 2023 17:17:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701566258; cv=none; d=google.com; s=arc-20160816; b=BpjxQpUSRkmljdXJaQf0a/1JBSbO7sZ5cpWl8A2fxn8pt89zJ6v/XSPcygmHnkjLU1 /Hxoemk+8arDZJlerz6DCseNAyF20wmmAr810XDlvvXl07GfuDsaazHwBDhKVRawY5JQ sZO+xXyz48mrzocSM1sYB+YIPpIGVkaNpvYOC6c6ocsEbsghmLZXetK2uMhXXX35St8w S41IVYuMPaOvKb0PxQzR1wpWcCF9klA/lashk0P/wHTr/ayfXLzKWFxnJvbo+fcRbXjU fgnjlYNatiNvqmRw8FKeQ/mmNNDj1tsAqzpdwCqxzINeuGvWbVABSLljP1RaVQhA2SQe V0mQ== 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=CiRe3KaMz7qXr4nqou1C0i3C+8hu1AhqYe4Mk2ycjxk=; fh=9Jm+Lxs1t24ggN0M2ysxzwgDGbo7w1pR16cQXOF6toE=; b=toKoI6Jn0qJBLpRziwiCMb2TeC/8qUFXId63XLZhnDUtXQFKIxXvCp31eoBlgDvtPg yUaqBUGYIxy5hJD8iGn4/NJb2bR0GFlPNrdVFXfKqqQTVGzv/fdZNltBPZH/IR97atql 3op8ewTF9wNEuZb4TZ4/IbmwqoVyGVe2DFN1T1UgmezKxBGw2VA6POg/aHjS0Yfn0oSH TjQnBDK3HO8BOUZWj/E44QktwoZ7VH/N8ZRLci2OFZAjKZqvwpEBlessqwJHz3ET7k9t 4eDPPjq0YbhVo7fV1qg18Rijy2dRo9KVW+FWDiolIoSCPyopF13z9lPWqVOJp14C8NF1 vEQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=qGRKkziC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id t18-20020a170902e85200b001d06d7f9134si2051746plg.97.2023.12.02.17.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 17:17:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=qGRKkziC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A446F80440E8; Sat, 2 Dec 2023 17:17:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231378AbjLCBNI (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Sat, 2 Dec 2023 20:13:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCBNH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 2 Dec 2023 20:13:07 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA21CBB for <linux-kernel@vger.kernel.org>; Sat, 2 Dec 2023 17:13:12 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33334480eb4so1477566f8f.0 for <linux-kernel@vger.kernel.org>; Sat, 02 Dec 2023 17:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1701565991; x=1702170791; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=CiRe3KaMz7qXr4nqou1C0i3C+8hu1AhqYe4Mk2ycjxk=; b=qGRKkziCucMhXyXECLDFB4ew8cLOsFh/RsJKfSB97B2WlzfsY5iPm8Reb3wpGcsl0J qKBTeeWMs7vqh3QI95HE5LAExPPvMM2WGb7g2y/UL54IWRzyrpuuXoWFF/t3+bgW5LSS TwgZa+uJgSMT/u42Wx2iKnAWb1oTn8obVWiYpEMJRXDlozmceZVqw3BTKV7APajFV1tp HhJFHwIRnilexLpH1GWH7H/P+SUM2clD3sFuErRlRppLDeTtStDUQ7I+K+hcG8cW81bK LL5POn0Ay4r7iXR+nDT1WtMNRONRFruVwUn7GRLOH5irPWqcI3uXzOOiEj+c9qxmcHPu Poew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701565991; x=1702170791; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CiRe3KaMz7qXr4nqou1C0i3C+8hu1AhqYe4Mk2ycjxk=; b=IThTw5+phF4B7M1vSgbSUbIU2abRjfqcJYEL1srR+GH9O1T1Dgsv5VXBvyRCD9hFa+ DK+z1k7jPMAeiooIzkPJsLDp/nG10C/EdcfPnpHvAslmPWAqn5Wp0UD2cCngeGNNRQ3H gwSohy0w8PQwzXf3agEzDrm6zk1QOMJjaD958dXZg+76ni4zPcPePdhJRxtrRHJ6Vuwu jB+oCOCNHet5ZDGUNcOwIjg27M9sCWGalBC1NOtPDnTq6OFWVS8dbIo+PLmmS9+vdFgZ 0mc69i/k6O2H+I4lTiwe9L2oACOYUpsRSLxAv1n4dA8r3+L6zJCl4qda9a6pTUgsocfM q7HQ== X-Gm-Message-State: AOJu0YwP6VuiEJFt/8eczVrFSCl4QNYzyrE1JWofRG+53e4eqDuCb4T/ KHxWWKnWZIwjGMHbUHhskJjwmw== X-Received: by 2002:a05:6000:c50:b0:332:f025:e339 with SMTP id do16-20020a0560000c5000b00332f025e339mr2298801wrb.19.1701565991325; Sat, 02 Dec 2023 17:13:11 -0800 (PST) Received: from airbuntu.. (host109-153-232-45.range109-153.btcentralplus.com. [109.153.232.45]) by smtp.gmail.com with ESMTPSA id p8-20020a5d59a8000000b003333ed23356sm1831781wrr.4.2023.12.02.17.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 17:13:10 -0800 (PST) From: Qais Yousef <qyousef@layalina.io> To: "Paul E. McKenney" <paulmck@kernel.org>, Joel Fernandes <joel@joelfernandes.org> Cc: Frederic Weisbecker <frederic@kernel.org>, Neeraj Upadhyay <quic_neeraju@quicinc.com>, Josh Triplett <josh@joshtriplett.org>, Boqun Feng <boqun.feng@gmail.com>, Steven Rostedt <rostedt@goodmis.org>, Mathieu Desnoyers <mathieu.desnoyers@efficios.com>, Lai Jiangshan <jiangshanlai@gmail.com>, Zqiang <qiang.zhang1211@gmail.com>, Andrea Righi <andrea.righi@canonical.com>, John Stultz <jstultz@google.com>, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, Qais Yousef <qyousef@layalina.io> Subject: [PATCH v2] rcu: Provide a boot time parameter to control lazy RCU Date: Sun, 3 Dec 2023 01:12:52 +0000 Message-Id: <20231203011252.233748-1-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,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 morse.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Sat, 02 Dec 2023 17:17:35 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784221541196251477 X-GMAIL-MSGID: 1784221541196251477 |
Series |
[v2] rcu: Provide a boot time parameter to control lazy RCU
|
|
Commit Message
Qais Yousef
Dec. 3, 2023, 1:12 a.m. UTC
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) <qyousef@layalina.io>
---
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(-)
Comments
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) <qyousef@layalina.io> 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 <andrea.righi@canonical.com> > --- > > 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
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) <qyousef@layalina.io> > > 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 <andrea.righi@canonical.com> 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
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) <qyousef@layalina.io> Thanks Qais, I have a comment below: > --- > > 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. > + I think a better approach is not do an anti-CONFIG option and instead do a shorter parameter "rcutree.lazy=0". If CONFIG_RCU_LAZY is set, then we can just default to keeping lazy on. I'd like to avoid proliferation of already large number of RCU config options and more chances of errors. I also want lazy to be ON for everybody configuring it into the kernel by default (those who don't want it just set CONFIG_RCU_LAZY=n), this is what tglx also suggested that's why we made changed of our initial prototypes of call_rcu_lazy() and instead we made call_rcu() to put everyone on the lazy train and not add more APIs (thus causing more confusion to kernel developers). This was a bit painful, but it was worth it. > 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); And then this can just be = true; thanks, - Joel > +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 >
On 12/05/23 16:20, Joel Fernandes wrote: > I think a better approach is not do an anti-CONFIG option and instead do > a shorter parameter "rcutree.lazy=0". If CONFIG_RCU_LAZY is set, then we can > just default to keeping lazy on. I'd like to avoid proliferation of already > large number of RCU config options and more chances of errors. The issue is that we don't want to ship with default on :-) > I also want lazy to be ON for everybody configuring it into the kernel by > default (those who don't want it just set CONFIG_RCU_LAZY=n), this is what This is still the default behavior. And all or nothing approach is not practical. You're telling me if I can't ship with default off, then I must disable it altogether. Adoption will become harder IMHO. > tglx also suggested that's why we made changed of our initial prototypes of > call_rcu_lazy() and instead we made call_rcu() to put everyone on the lazy > train and not add more APIs (thus causing more confusion to kernel > developers). This was a bit painful, but it was worth it. I think implementation details make sense, but orthogonal to the problem of enabling CONFIG_RCU_LAZY=y but still ship with default off. It is a risky change and we want to start staging with default off first. Not allowing this in upstream means I'll either have to resort to keep it disabled, or carry out of tree patch to get what I want. Both of which would be unfortunate. Thanks! -- Qais Yousef
On 12/7/23 12:20, Qais Yousef wrote: > On 12/05/23 16:20, Joel Fernandes wrote: > >> I think a better approach is not do an anti-CONFIG option and instead do >> a shorter parameter "rcutree.lazy=0". If CONFIG_RCU_LAZY is set, then we can >> just default to keeping lazy on. I'd like to avoid proliferation of already >> large number of RCU config options and more chances of errors. > > The issue is that we don't want to ship with default on :-) Yes, so you can ship with rcutree.enable_lazy=0 which this patch adds, no? In theory, you can accomplish this by simply CONFIG_RCU_LAZY=y and rcutree.enable_lazy=0 or rcutree.lazy=0. However, I see the inconvenience factor (you have to set a boot parameter without making this a purely .config affair) so I am not terribly opposed with this patch (I am also guilty of adding a CONFIG option to avoid having to set a boot parameter (for unrelated feature), but in my defense I did not know a boot parameter existed for the said feature). ;-) >> I also want lazy to be ON for everybody configuring it into the kernel by >> default (those who don't want it just set CONFIG_RCU_LAZY=n), this is what > > This is still the default behavior. > > And all or nothing approach is not practical. You're telling me if I can't ship > with default off, then I must disable it altogether. Adoption will become > harder IMHO. No, that's not what I said. You misunderstood me (which is probably my fault at not being more clear). It is not all or nothing. I am just saying you can accomplish "default off" by just setting the boot parameter. With this patch, you are not willing to do that out of convenience, which I can understand but still we should at least have a discussion about that. > >> tglx also suggested that's why we made changed of our initial prototypes of >> call_rcu_lazy() and instead we made call_rcu() to put everyone on the lazy >> train and not add more APIs (thus causing more confusion to kernel >> developers). This was a bit painful, but it was worth it. > > I think implementation details make sense, but orthogonal to the problem of > enabling CONFIG_RCU_LAZY=y but still ship with default off. It is a risky > change and we want to start staging with default off first. Never had any issue with that. I very much want to see this safely rolled out to Android. ;-) > Not allowing this > in upstream means I'll either have to resort to keep it disabled, or carry out > of tree patch to get what I want. Both of which would be unfortunate. There is already precedent for building things into the kernel but keeping them default off, so I don't have an issue with the experimentation use case. I was just discussing whether the additional CONFIG is really needed when you already have added a boot param to keep it default-off. If you have an argument for why that would be really helpful [1]. Also, nit: rcutree.enable_lazy is probably better than rcutree.enable_rcu_lazy. The 'rcu' is redundant. Other than that, the patch LGTM but if you could update the commit log with details about [1], that would be great. And while at it, you could add my tag: Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> thanks, - Joel
On 12/09/23 01:26, Joel Fernandes wrote: > On 12/7/23 12:20, Qais Yousef wrote: > > On 12/05/23 16:20, Joel Fernandes wrote: > > > >> I think a better approach is not do an anti-CONFIG option and instead do > >> a shorter parameter "rcutree.lazy=0". If CONFIG_RCU_LAZY is set, then we can > >> just default to keeping lazy on. I'd like to avoid proliferation of already > >> large number of RCU config options and more chances of errors. > > > > The issue is that we don't want to ship with default on :-) > > Yes, so you can ship with rcutree.enable_lazy=0 which this patch adds, no? In > theory, you can accomplish this by simply CONFIG_RCU_LAZY=y and > rcutree.enable_lazy=0 or rcutree.lazy=0. > > However, I see the inconvenience factor (you have to set a boot parameter > without making this a purely .config affair) so I am not terribly opposed with > this patch (I am also guilty of adding a CONFIG option to avoid having to set a > boot parameter (for unrelated feature), but in my defense I did not know a boot > parameter existed for the said feature). ;-) It is more than inconvenience. The GKI doesn't ship with a specific userspace. So we can't guarantee the boot parameter will be set and have to rely on no one missing the memo to add this additional parameter. And to speed up adoption and testing, I am backporting the feature to 5.10, 5.15 and 6.1. It is risky enough to get a backport, but to default on it could introduce more subtle surprises. But not doing so we could end up waiting for 2 years before enough people move to the latest LTS that contains the feature. > > >> I also want lazy to be ON for everybody configuring it into the kernel by > >> default (those who don't want it just set CONFIG_RCU_LAZY=n), this is what > > > > This is still the default behavior. > > > > And all or nothing approach is not practical. You're telling me if I can't ship > > with default off, then I must disable it altogether. Adoption will become > > harder IMHO. > > No, that's not what I said. You misunderstood me (which is probably my fault at > not being more clear). It is not all or nothing. I am just saying you can > accomplish "default off" by just setting the boot parameter. With this patch, > you are not willing to do that out of convenience, which I can understand but > still we should at least have a discussion about that. Okay, sorry if I misunderstood. > > > > >> tglx also suggested that's why we made changed of our initial prototypes of > >> call_rcu_lazy() and instead we made call_rcu() to put everyone on the lazy > >> train and not add more APIs (thus causing more confusion to kernel > >> developers). This was a bit painful, but it was worth it. > > > > I think implementation details make sense, but orthogonal to the problem of > > enabling CONFIG_RCU_LAZY=y but still ship with default off. It is a risky > > change and we want to start staging with default off first. > > Never had any issue with that. I very much want to see this safely rolled out to > Android. ;-) > > > Not allowing this > > in upstream means I'll either have to resort to keep it disabled, or carry out > > of tree patch to get what I want. Both of which would be unfortunate. > > There is already precedent for building things into the kernel but keeping them > default off, so I don't have an issue with the experimentation use case. I was > just discussing whether the additional CONFIG is really needed when you already > have added a boot param to keep it default-off. If you have an argument for why > that would be really helpful [1]. > > Also, nit: rcutree.enable_lazy is probably better than rcutree.enable_rcu_lazy. > The 'rcu' is redundant. It matches the config option so feels natural to have them both named the same? > > Other than that, the patch LGTM but if you could update the commit log with > details about [1], that would be great. And while at it, you could add my tag: You forgot to include [1]? Or I'm just blind today? > > Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> Thanks! -- Qais Yousef
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) <qyousef@layalina.io> > --- > > 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); > I think, it makes sense. Especially for devices/systems where it is hard to recompile the kernel and deploy it. For example, Google and GKI approach. Reviewed-by: Uladzislau Rezki (Sony) <urezki@gmail.com> -- Uladzislau Rezki
On Tue, Dec 12, 2023 at 7:35 AM Uladzislau Rezki <urezki@gmail.com> 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) <qyousef@layalina.io> > > --- > > > > 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); > > > I think, it makes sense. Especially for devices/systems where it is hard > to recompile the kernel and deploy it. For example, Google and GKI approach. My concerns had nothing to do with recompiling the kernel. Passing a boot parameter (without a kernel compile) can just as well default-disable the feature. I think what Qais is saying is that passing a boot parameter is itself a hassle in Android (something I did not know about) because of GKI etc. thanks, - Joel
On Tue, Dec 12, 2023 at 7:05 AM Qais Yousef <qyousef@layalina.io> wrote: > > On 12/09/23 01:26, Joel Fernandes wrote: > > On 12/7/23 12:20, Qais Yousef wrote: > > > On 12/05/23 16:20, Joel Fernandes wrote: > > > > > >> I think a better approach is not do an anti-CONFIG option and instead do > > >> a shorter parameter "rcutree.lazy=0". If CONFIG_RCU_LAZY is set, then we can > > >> just default to keeping lazy on. I'd like to avoid proliferation of already > > >> large number of RCU config options and more chances of errors. > > > > > > The issue is that we don't want to ship with default on :-) > > > > Yes, so you can ship with rcutree.enable_lazy=0 which this patch adds, no? In > > theory, you can accomplish this by simply CONFIG_RCU_LAZY=y and > > rcutree.enable_lazy=0 or rcutree.lazy=0. > > > > However, I see the inconvenience factor (you have to set a boot parameter > > without making this a purely .config affair) so I am not terribly opposed with > > this patch (I am also guilty of adding a CONFIG option to avoid having to set a > > boot parameter (for unrelated feature), but in my defense I did not know a boot > > parameter existed for the said feature). ;-) > > It is more than inconvenience. The GKI doesn't ship with a specific userspace. > So we can't guarantee the boot parameter will be set and have to rely on no one > missing the memo to add this additional parameter. Yes, I see that now. Looks like Android also needs to be supplying a "GKI boot parameter" requirement to their GKI supplied kernels ;-). But I see the issue you are referring to now. It would be good to add these details to your respin. > > > Not allowing this > > > in upstream means I'll either have to resort to keep it disabled, or carry out > > > of tree patch to get what I want. Both of which would be unfortunate. > > > > There is already precedent for building things into the kernel but keeping them > > default off, so I don't have an issue with the experimentation use case. I was > > just discussing whether the additional CONFIG is really needed when you already > > have added a boot param to keep it default-off. If you have an argument for why > > that would be really helpful [1]. > > > > Also, nit: rcutree.enable_lazy is probably better than rcutree.enable_rcu_lazy. > > The 'rcu' is redundant. > > It matches the config option so feels natural to have them both named the same? Ok, either is fine with me. > > Other than that, the patch LGTM but if you could update the commit log with > > details about [1], that would be great. And while at it, you could add my tag: > > You forgot to include [1]? Or I'm just blind today? Heh, if you search "[1]" you see it above where I said "helpful". ;-). But apologies if I caused confusion. thanks, - Joel > > > > > Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> > > Thanks! > > -- > Qais Yousef
On Tue, Dec 12, 2023 at 05:28:54PM -0500, Joel Fernandes wrote: > On Tue, Dec 12, 2023 at 7:35 AM Uladzislau Rezki <urezki@gmail.com> 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) <qyousef@layalina.io> > > > --- > > > > > > 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); > > > > > I think, it makes sense. Especially for devices/systems where it is hard > > to recompile the kernel and deploy it. For example, Google and GKI approach. > > My concerns had nothing to do with recompiling the kernel. Passing a > boot parameter (without a kernel compile) can just as well > default-disable the feature. > > I think what Qais is saying is that passing a boot parameter is itself > a hassle in Android (something I did not know about) because of GKI > etc. > That is true. Doing: echo 1 > /sys/.../enable_lazy is a way how to make it easy and flexible. -- Uladzislau Rezki
On Wed, Dec 13, 2023 at 5:35 AM Uladzislau Rezki <urezki@gmail.com> wrote: [....] > > > > + 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); > > > > > > > I think, it makes sense. Especially for devices/systems where it is hard > > > to recompile the kernel and deploy it. For example, Google and GKI approach. > > > > My concerns had nothing to do with recompiling the kernel. Passing a > > boot parameter (without a kernel compile) can just as well > > default-disable the feature. > > > > I think what Qais is saying is that passing a boot parameter is itself > > a hassle in Android (something I did not know about) because of GKI > > etc. > > > That is true. Doing: > > echo 1 > /sys/.../enable_lazy > > is a way how to make it easy and flexible. Hey Vlad, are you suggesting that the boot parameter be made to support runtime? We can keep that for later as it may get complicated. Qais's boot parameter is designed only for boot time. Qais, could you resend the patch with our tags and updated description? Thanks, - Joel
Hello, Joel! > [....] > > > > > + 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); > > > > > > > > > I think, it makes sense. Especially for devices/systems where it is hard > > > > to recompile the kernel and deploy it. For example, Google and GKI approach. > > > > > > My concerns had nothing to do with recompiling the kernel. Passing a > > > boot parameter (without a kernel compile) can just as well > > > default-disable the feature. > > > > > > I think what Qais is saying is that passing a boot parameter is itself > > > a hassle in Android (something I did not know about) because of GKI > > > etc. > > > > > That is true. Doing: > > > > echo 1 > /sys/.../enable_lazy > > > > is a way how to make it easy and flexible. > > Hey Vlad, are you suggesting that the boot parameter be made to > support runtime? We can keep that for later as it may get complicated. > Qais's boot parameter is designed only for boot time. > No problem. Yes, i meant a runtime one. But as you stated there might be hidden issues witch we are not aware of yet. Thanks! -- Uladzislau Rezki
On Fri, Dec 15, 2023 at 05:58:55PM +0100, Uladzislau Rezki wrote: > Hello, Joel! > > > [....] > > > > > > + 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); > > > > > > > > > > > I think, it makes sense. Especially for devices/systems where it is hard > > > > > to recompile the kernel and deploy it. For example, Google and GKI approach. > > > > > > > > My concerns had nothing to do with recompiling the kernel. Passing a > > > > boot parameter (without a kernel compile) can just as well > > > > default-disable the feature. > > > > > > > > I think what Qais is saying is that passing a boot parameter is itself > > > > a hassle in Android (something I did not know about) because of GKI > > > > etc. > > > > > > > That is true. Doing: > > > > > > echo 1 > /sys/.../enable_lazy > > > > > > is a way how to make it easy and flexible. > > > > Hey Vlad, are you suggesting that the boot parameter be made to > > support runtime? We can keep that for later as it may get complicated. > > Qais's boot parameter is designed only for boot time. > > > No problem. Yes, i meant a runtime one. But as you stated there might > be hidden issues witch we are not aware of yet. My current thought is that Qais's version currently in -rcu for the merge window after next (v6.9) suits our current situation. But if we are eventually able to support runtime changes to this new rcutree.enable_rcu_lazy module parameter via simplification to the rcu_nocb_try_bypass() function (or maybe a better analysis of it), then at that point it would be good to allow this module parameter to be changed via sysfs at runtime. Does that make sense, or am I missing some aspect or use case? Thanx, Paul
On Fri, Dec 15, 2023 at 1:46 PM Paul E. McKenney <paulmck@kernel.org> wrote: > > On Fri, Dec 15, 2023 at 05:58:55PM +0100, Uladzislau Rezki wrote: > > Hello, Joel! > > > > > [....] > > > > > > > + 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); > > > > > > > > > > > > > I think, it makes sense. Especially for devices/systems where it is hard > > > > > > to recompile the kernel and deploy it. For example, Google and GKI approach. > > > > > > > > > > My concerns had nothing to do with recompiling the kernel. Passing a > > > > > boot parameter (without a kernel compile) can just as well > > > > > default-disable the feature. > > > > > > > > > > I think what Qais is saying is that passing a boot parameter is itself > > > > > a hassle in Android (something I did not know about) because of GKI > > > > > etc. > > > > > > > > > That is true. Doing: > > > > > > > > echo 1 > /sys/.../enable_lazy > > > > > > > > is a way how to make it easy and flexible. > > > > > > Hey Vlad, are you suggesting that the boot parameter be made to > > > support runtime? We can keep that for later as it may get complicated. > > > Qais's boot parameter is designed only for boot time. > > > > > No problem. Yes, i meant a runtime one. But as you stated there might > > be hidden issues witch we are not aware of yet. > > My current thought is that Qais's version currently in -rcu for > the merge window after next (v6.9) suits our current situation. > But if we are eventually able to support runtime changes to this new > rcutree.enable_rcu_lazy module parameter via simplification to the > rcu_nocb_try_bypass() function (or maybe a better analysis of it), > then at that point it would be good to allow this module parameter to > be changed via sysfs at runtime. Yes, that's right. > Does that make sense, or am I missing some aspect or use case? No you are not missing anything. Thanks.
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);