Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1953379rdb; Sat, 2 Dec 2023 17:17:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxXoqwH4UHTPfxRpxoyo9IqlQgbpkNcrzC8Ys8W84kgTWRxyiEuzMCU6bRRz5J4ChU781H X-Received: by 2002:a05:6870:b30e:b0:1fa:fd76:8282 with SMTP id a14-20020a056870b30e00b001fafd768282mr2596719oao.40.1701566261937; Sat, 02 Dec 2023 17:17:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701566261; cv=none; d=google.com; s=arc-20160816; b=Y/fARaxhoQNiMF6d2TPDX6/NEkPUAbXDApTQ6Snj6++UE7Li0hUoUQiiTmlw3NZdVq Qa469oOqXVDaeS/9z33IiGh58soUTEn9OhyFU/a/5r6fEZ/q/AL5KJDm9d+C3YT8iVMl Ylf/OSyMJfO7bsJXGkyv4Pk1ecJUIcDlydEq9AsMohCLN8eLB//2+hd/sMY0+BmGYOo0 UyTDl57j53UT9wxXTA/iY9vgmR9XYn5fu65JsVsuIIpLvZicTjpJVb2E9RZFih+MP+fu EGIMIu679+8taPjFitvV0hu3dibhbTLIgqs1beIzgFQow9JeKX8Xs6ws+yChn3tJoKwN 5XCw== 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 Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id t5-20020a170902b20500b001d08d307f89si280310plr.496.2023.12.02.17.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Dec 2023 17:17:41 -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 65C6980440E8; Sat, 2 Dec 2023 17:17:39 -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 + 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 ); 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-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: 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: 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:39 -0800 (PST) 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) --- 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