From nobody Mon Dec 29 00:41:20 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFE98C10DC1 for ; Sun, 3 Dec 2023 01:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231789AbjLCBNI (ORCPT ); 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 ); 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 ; Sat, 2 Dec 2023 17:13:12 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-33334480eb4so1477566f8f.0 for ; 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-Google-Smtp-Source: AGHT+IHRIfzLa8YKlslVe+YOb7SeJ6FggyLmRoDeS1w2HTCzwgsZ+I0NVpr/1ksa5YIq6cpJpDUUPw== 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 To: "Paul E. McKenney" , Joel Fernandes Cc: Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Boqun Feng , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Andrea Righi , John Stultz , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, Qais Yousef 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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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=3D[y|1|n|0] Which also requires rcu_nocbs=3Dall at boot time to enable/disable lazy RCU. To disable it by default at build time when CONFIG_RCU_LAZY=3Dy, the new CONFIG_RCU_LAZY_DEFAULT_OFF can be used. Signed-off-by: Qais Yousef (Google) Reviewed-by: Joel Fernandes (Google) Reviewed-by: Uladzislau Rezki (Sony) Tested-by: Andrea Righi --- 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 ens= ure 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/Documentatio= n/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. =20 + rcutree.enable_rcu_lazy=3D [KNL] + To save power, batch RCU callbacks and flush after + delay, memory pressure or callback list growing too + big. + rcuscale.gp_async=3D [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. =20 + Requires rcu_nocbs=3Dall to be set. + + Use rcutree.enable_rcu_lazy=3D0 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=3Dy yet keep it default + off. Boot time param rcutree.enable_rcu_lazy=3D1 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) } =20 #ifdef CONFIG_RCU_LAZY +static bool enable_rcu_lazy __read_mostly =3D !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 w= hile @@ -2744,6 +2747,8 @@ void call_rcu_hurry(struct rcu_head *head, rcu_callba= ck_t func) __call_rcu_common(head, func, false); } EXPORT_SYMBOL_GPL(call_rcu_hurry); +#else +#define enable_rcu_lazy false #endif =20 /** @@ -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); =20 --=20 2.34.1