From: "Paul E. McKenney" <paulmck@kernel.org>
To: rcu@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
rostedt@goodmis.org, "Paul E. McKenney" <paulmck@kernel.org>
Subject: [PATCH rcu 18/19] srcu: Automatically determine size-transition strategy at boot
Date: Fri, 4 Feb 2022 15:39:01 -0800 [thread overview]
Message-ID: <20220204233902.1902-18-paulmck@kernel.org> (raw)
In-Reply-To: <20220204233858.GA1469@paulmck-ThinkPad-P17-Gen-1>
This commit adds a srcutree.convert_to_big option of zero that causes
SRCU to decide at boot whether to wait for contention (small systems) or
immediately expand to large (large systems). A new srcutree.big_cpu_lim
(defaulting to 128) defines how many CPUs constitute a large system.
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
---
.../admin-guide/kernel-parameters.txt | 9 +++++++++
kernel/rcu/srcutree.c | 19 ++++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index d7b64263fefbc..ad2388a431944 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5525,11 +5525,20 @@
off: Disable mitigation and remove
performance impact to RDRAND and RDSEED
+ srcutree.big_cpu_lim [KNL]
+ Specifies the number of CPUs constituting a
+ large system, such that srcu_struct structures
+ should immediately allocate an srcu_node array.
+ This kernel-boot parameter defaults to 128, but
+ takes effect only when srcutree.convert_to_big
+ is equal to zero.
+
srcutree.convert_to_big [KNL]
Specifies under what conditions an SRCU tree
srcu_struct structure will be converted to big
form, that is, with an rcu_node tree:
+ 0: Decide at boot time (default).
1: Never.
2: At init_srcu_struct() time.
3: When rcutorture decides to.
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index f13e84ecbca6a..c3968e091d019 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -57,9 +57,13 @@ module_param(counter_wrap_check, ulong, 0444);
#define SRCU_SIZING_IS_INIT() (SRCU_SIZING_IS(SRCU_SIZING_INIT))
#define SRCU_SIZING_IS_TORTURE() (SRCU_SIZING_IS(SRCU_SIZING_TORTURE))
#define SRCU_SIZING_IS_CONTEND() (convert_to_big & SRCU_SIZING_CONTEND)
-static int convert_to_big = SRCU_SIZING_NONE;
+static int convert_to_big = SRCU_SIZING_AUTO;
module_param(convert_to_big, int, 0444);
+/* Number of CPUs to trigger init_srcu_struct()-time transition to big. */
+static int big_cpu_lim __read_mostly = 128;
+module_param(big_cpu_lim, int, 0444);
+
/* Contention events per jiffy to initiate transition to big. */
static int small_contention_lim __read_mostly = 100;
module_param(small_contention_lim, int, 0444);
@@ -1592,6 +1596,17 @@ void __init srcu_init(void)
{
struct srcu_struct *ssp;
+ /* Decide on srcu_struct-size strategy. */
+ if (SRCU_SIZING_IS(SRCU_SIZING_AUTO)) {
+ if (nr_cpu_ids >= big_cpu_lim) {
+ convert_to_big = SRCU_SIZING_INIT; // Don't bother waiting for contention.
+ pr_info("%s: Setting srcu_struct sizes to big.\n", __func__);
+ } else {
+ convert_to_big = SRCU_SIZING_NONE | SRCU_SIZING_CONTEND;
+ pr_info("%s: Setting srcu_struct sizes based on contention.\n", __func__);
+ }
+ }
+
/*
* Once that is set, call_srcu() can follow the normal path and
* queue delayed work. This must follow RCU workqueues creation
@@ -1602,6 +1617,8 @@ void __init srcu_init(void)
ssp = list_first_entry(&srcu_boot_list, struct srcu_struct,
work.work.entry);
list_del_init(&ssp->work.work.entry);
+ if (SRCU_SIZING_IS(SRCU_SIZING_INIT) && !ssp->srcu_size_state)
+ ssp->srcu_size_state = SRCU_SIZE_ALLOC;
queue_work(rcu_gp_wq, &ssp->work.work);
}
}
--
2.31.1.189.g2e36527f23
next prev parent reply other threads:[~2022-02-04 23:39 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 23:38 [PATCH rcu 0/19] SRCU updates for v5.18 Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 01/19] srcu: Tighten cleanup_srcu_struct() GP checks Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 02/19] srcu: Fix s/is/if/ typo in srcu_node comment Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 03/19] srcu: Make srcu_funnel_gp_start() cache ->mynode in snp_leaf Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 04/19] srcu: Dynamically allocate srcu_node array Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 05/19] srcu: Make Tree SRCU able to operate without snp_node array Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 06/19] srcu: Add size-state transitioning code Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 07/19] srcu: Make rcutorture dump the SRCU size state Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 08/19] srcu: Add boot-time control over srcu_node array allocation Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 09/19] srcu: Use export for srcu_struct defined by DEFINE_STATIC_SRCU() Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 10/19] srcu: Compute snp_seq earlier in srcu_funnel_gp_start() Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 11/19] srcu: Use invalid initial value for srcu_node GP sequence numbers Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 12/19] srcu: Avoid NULL dereference in srcu_torture_stats_print() Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 13/19] srcu: Prevent cleanup_srcu_struct() from freeing non-dynamic ->sda Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 14/19] srcu: Explain srcu_funnel_gp_start() call to list_add() is safe Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 15/19] srcu: Create concurrency-safe helper for initiating size transition Paul E. McKenney
2022-02-04 23:38 ` [PATCH rcu 16/19] srcu: Add contention-triggered addition of srcu_node tree Paul E. McKenney
2022-02-04 23:39 ` [PATCH rcu 17/19] srcu: Make srcu_size_state_name static Paul E. McKenney
2022-02-04 23:39 ` Paul E. McKenney [this message]
2022-02-04 23:39 ` [PATCH rcu 19/19] srcu: Add contention check to call_srcu() srcu_data ->lock acquisition Paul E. McKenney
[not found] ` <20220205030303.2408-1-hdanton@sina.com>
2022-02-05 5:20 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220204233902.1902-18-paulmck@kernel.org \
--to=paulmck@kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rcu@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox