Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2161191rdb; Sun, 3 Dec 2023 05:19:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IE2LO0/qG6FIR381RP6hlk8q58NqvtgyUrFM4wLGnQphMjSZPnBp4ERtZWgDKbjHnayAHSe X-Received: by 2002:a05:6830:6284:b0:6d8:74e2:7cdd with SMTP id ce4-20020a056830628400b006d874e27cddmr4340833otb.56.1701609562436; Sun, 03 Dec 2023 05:19:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701609562; cv=none; d=google.com; s=arc-20160816; b=bRssvDnhRHKlggIQe42QX7VwNlqjhX8+GWKBmJB2daWGHgbVA3L0B2g3Yy9UWw4uIl DK255Cdzy4+rmXk9PUeIK4tv0SUo/MKYj6R3BRKkhHEY8v86h7hP7boMPy1baat1J2di 33tnm3AmEo1TdYIWdWXUTKIzcbZTWMdtoNYuguVm1TRXWVfsTTT2JJu+/p1I0KXHrOww JsPPkDy398juaWav2zTgMoPP34irWgqBHJSyJGrqrZAcZKW9ecrS5Bt2BLImhrkk6Amy 7X6mERMyoPubAzuhl/+vv8V6dy1HOUzxfnpCCOMWP2qVy+tnRi/6igYarwIjTyS0vklj COYg== 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:message-id:subject:cc:to:from:date:dkim-signature; bh=HHmlffykkOJ0/mztigbZgIMRb64RNyQwKkrsR2WWoBM=; fh=XL9jCX+ingpPwdPFxWxiB3LumY3gDKZC/hIv8jICx+0=; b=a5Q2NgOxqZ9jXdy/IggHuZAmkumXC9yGn4Z2gSvKlxJrG6rb+jH35m4DXtW7fIViya /Vstou1HcAE7nIeBXt7EFqxTDIaMve9gX6IiElUvZCsEFOGejb+FVVMFpfetXhyPvLYr w9NWHll1uu2w8kkvt35fZowbhpaMmoxTRc9KOJW2vTB9uvLC3a5wGCPlJ+VY4gxM6UG6 vNuVx6L59Q8PCWuvh7laEH/RKpk5BVMPTFY6pDD7pat2DMI3re2BmbfvFl1tjps7excr yIASomgwR10yGi0PAxCFXn3+KLB8VM790pb+5O3zsHy3c7hK/IzsY60SRXuSTgN4KW66 uVuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=odqrkkPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h14-20020a056a00230e00b006cbe53e19fdsi6328263pfh.222.2023.12.03.05.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 05:19:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=odqrkkPO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C4004805B2CF; Sun, 3 Dec 2023 05:19:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233764AbjLCNSt (ORCPT + 99 others); Sun, 3 Dec 2023 08:18:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233671AbjLCNSb (ORCPT ); Sun, 3 Dec 2023 08:18:31 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F6A198 for ; Sun, 3 Dec 2023 05:18:24 -0800 (PST) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 7B04A3F18D for ; Sun, 3 Dec 2023 13:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1701609502; bh=HHmlffykkOJ0/mztigbZgIMRb64RNyQwKkrsR2WWoBM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=odqrkkPOfA2hY4agb9CGyTHn1K2SUxWeLt0k8YpiCqxIAvcq+C/XfhyyEftc+pvl8 RKb/VxnXZboQNWKiQnWNu1iZt+pMtoRcShPGdrPasiegEXAeG3TCFAsp/4h/OIHaYa g+LTPDn2ZHE1CfQTgCf1Rl0BRuKYIS9fnXylxpwU2+JjTIM3NubEM+cz2N4lp4ikrc 79Qco/b1aGotLzoA4Jt+EaAozxGZ1G/PK4C/e+Ugh54k5nFyTo9DTR3LDGYN/oknxe tCEG/kGC6fKUl2TLmWREPLMHZf1IfrzbuB20KsCCSvHKlNYkbfnXcv8aOSp/NQ76qz inDKWdpfsF4qQ== Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-332e11a22a0so3201889f8f.2 for ; Sun, 03 Dec 2023 05:18:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701609502; x=1702214302; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HHmlffykkOJ0/mztigbZgIMRb64RNyQwKkrsR2WWoBM=; b=n6PIzlZzpeYmZf2QBPK5wFiKrfZdDE4QYlGN08wV/nA7dvdFPc7xSs0ML+TQNSc/Xd znWao3m8faRPPBZjFnsZa8nn72LetmrjgJLFptF2BFYc5oYY5eNfLcDQ63hupFYR5uxV 5dodsl/uJLcfFcYwnxtv53Hq6MXVnKKCPNDZvu/21FwnX/LVpyEplKCgYGrywE1ZYBGs 0V03rcrhyesuJ9Svv15A0UlXcjQXBlJkz2eAUJ1mebGE/PepS499HKv+nLOcPmDLYGy9 lQz+oLxSn76nZMyqQsYdFZJL+GthM5KNWpg0kNdzoo7z+KTLskhNF/NU2CmmIvYfmz+n TnAw== X-Gm-Message-State: AOJu0YwNwaz4jhYaH8pGQjk0q9U8GrViKGsaryscO3Efxp8/B++cDlCa /Wje5CJxFudzxEiW/7HFwijyIh23F4hLY9qqhelQFzdXPe64ioqAiZehOFHGxf5Ss3fupyNwHC8 rjPo0xGUfo8ZUWKRhBhjzrxLW9qDsNpZjjiGrA9TT5w== X-Received: by 2002:a05:600c:548c:b0:40b:5e21:bdc9 with SMTP id iv12-20020a05600c548c00b0040b5e21bdc9mr1533779wmb.88.1701609502086; Sun, 03 Dec 2023 05:18:22 -0800 (PST) X-Received: by 2002:a05:600c:548c:b0:40b:5e21:bdc9 with SMTP id iv12-20020a05600c548c00b0040b5e21bdc9mr1533753wmb.88.1701609501096; Sun, 03 Dec 2023 05:18:21 -0800 (PST) Received: from localhost (host-79-35-130-102.retail.telecomitalia.it. [79.35.130.102]) by smtp.gmail.com with ESMTPSA id hd37-20020a17090796a500b009c503bf61c9sm4083032ejc.165.2023.12.03.05.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 05:18:20 -0800 (PST) Date: Sun, 3 Dec 2023 14:18:19 +0100 From: Andrea Righi To: Qais Yousef Cc: "Paul E. McKenney" , 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: References: <20231203011252.233748-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231203011252.233748-1-qyousef@layalina.io> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 howler.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 (howler.vger.email [0.0.0.0]); Sun, 03 Dec 2023 05:19:19 -0800 (PST) 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 > --- > > 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