From: "Joel Fernandes (Google)" <joel@joelfernandes.org>
To: linux-kernel@vger.kernel.org
Cc: "Joel Fernandes (Google)" <joel@joelfernandes.org>,
Frederic Weisbecker <frederic@kernel.org>,
Lai Jiangshan <jiangshanlai@gmail.com>,
linux-doc@vger.kernel.org,
"Paul E. McKenney" <paulmck@kernel.org>,
rcu@vger.kernel.org
Subject: [PATCH RFC v2] rcu: Add a minimum time for marking boot as completed
Date: Sat, 25 Feb 2023 03:34:21 +0000 [thread overview]
Message-ID: <20230225033421.3323164-1-joel@joelfernandes.org> (raw)
On many systems, a great deal of boot happens after the kernel thinks the boot
has completed. It is difficult to determine if the system has really booted
from the kernel side. Some features like lazy-RCU can risk slowing down boot
time if, say, a callback has been added that the boot synchronously depends on.
Further, it is better to boot systems which pass 'rcu_normal_after_boot' to
stay expedited for as long as the system is still booting.
For these reasons, this commit adds a config option
'CONFIG_RCU_BOOT_END_DELAY' and a boot parameter rcupdate.boot_end_delay.
By default, this value is 20s. A system designer can choose to specify a value
here to keep RCU from marking boot completion. The boot sequence will not be
marked ended until at least boot_end_delay milliseconds have passed.
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
v1->v2:
Update some comments and description.
.../admin-guide/kernel-parameters.txt | 4 +++
cc_list | 7 ++++++
kernel/rcu/Kconfig | 12 +++++++++
kernel/rcu/update.c | 25 +++++++++++++++++--
4 files changed, 46 insertions(+), 2 deletions(-)
create mode 100644 cc_list
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 2429b5e3184b..0943139fdf01 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -5085,6 +5085,10 @@
rcutorture.verbose= [KNL]
Enable additional printk() statements.
+ rcupdate.boot_end_delay= [KNL]
+ Minimum time that must elapse before the boot
+ sequence can be marked as completed.
+
rcupdate.rcu_cpu_stall_ftrace_dump= [KNL]
Dump ftrace buffer after reporting RCU CPU
stall warning.
diff --git a/kernel/rcu/Kconfig b/kernel/rcu/Kconfig
index 9071182b1284..0d77006a948f 100644
--- a/kernel/rcu/Kconfig
+++ b/kernel/rcu/Kconfig
@@ -217,6 +217,18 @@ config RCU_BOOST_DELAY
Accept the default if unsure.
+config RCU_BOOT_END_DELAY
+ int "Minimum time before RCU may consider in-kernel boot as completed"
+ range 0 120000
+ default 20000
+ help
+ This option specifies the minimum time in milliseconds from boot start
+ before RCU believes boot has completed. The actual delay can be
+ higher than this if the kernel takes a long time to initialize
+ but it will never be smaller than this.
+
+ Accept the default if unsure.
+
config RCU_EXP_KTHREAD
bool "Perform RCU expedited work in a real-time kthread"
depends on RCU_BOOST && RCU_EXPERT
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c
index 19bf6fa3ee6a..cbdad7b46841 100644
--- a/kernel/rcu/update.c
+++ b/kernel/rcu/update.c
@@ -62,6 +62,10 @@ module_param(rcu_normal_after_boot, int, 0444);
#endif
#endif /* #ifndef CONFIG_TINY_RCU */
+/* Minimum time in ms until RCU can consider in-kernel boot as completed. */
+static int boot_end_delay = CONFIG_RCU_BOOT_END_DELAY;
+module_param(boot_end_delay, int, 0444);
+
#ifdef CONFIG_DEBUG_LOCK_ALLOC
/**
* rcu_read_lock_held_common() - might we be in RCU-sched read-side critical section?
@@ -225,12 +229,29 @@ void rcu_unexpedite_gp(void)
EXPORT_SYMBOL_GPL(rcu_unexpedite_gp);
static bool rcu_boot_ended __read_mostly;
-
/*
- * Inform RCU of the end of the in-kernel boot sequence.
+ * Inform RCU of the end of the in-kernel boot sequence. The boot sequence will
+ * not be marked ended until at least boot_end_delay milliseconds have passed.
*/
+void rcu_end_inkernel_boot(void);
+static void boot_rcu_work_fn(struct work_struct *work)
+{
+ rcu_end_inkernel_boot();
+}
+static DECLARE_DELAYED_WORK(boot_rcu_work, boot_rcu_work_fn);
+
void rcu_end_inkernel_boot(void)
{
+ if (boot_end_delay) {
+ u64 boot_ms = ktime_get_boot_fast_ns() / 1000000UL;
+
+ if (boot_ms < boot_end_delay) {
+ schedule_delayed_work(&boot_rcu_work,
+ boot_end_delay - boot_ms);
+ return;
+ }
+ }
+
rcu_unexpedite_gp();
rcu_async_relax();
if (rcu_normal_after_boot)
--
2.39.2.637.g21b0678d19-goog
next reply other threads:[~2023-02-25 3:34 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-25 3:34 Joel Fernandes (Google) [this message]
2023-02-25 3:36 ` Randy Dunlap
2023-02-26 19:45 ` Frederic Weisbecker
2023-02-26 23:07 ` Joel Fernandes
2023-02-27 7:53 ` Zhuo, Qiuxu
2023-02-27 13:22 ` Joel Fernandes
2023-02-27 14:55 ` Paul E. McKenney
2023-02-27 15:16 ` Joel Fernandes
2023-02-27 18:06 ` Uladzislau Rezki
2023-02-27 18:15 ` Joel Fernandes
2023-02-27 18:20 ` Uladzislau Rezki
2023-02-27 18:27 ` Joel Fernandes
2023-02-27 18:57 ` Uladzislau Rezki
2023-02-27 19:10 ` Joel Fernandes
2023-02-27 23:05 ` Paul E. McKenney
2023-02-27 23:24 ` Joel Fernandes
2023-02-27 23:40 ` Frederic Weisbecker
2023-02-28 1:30 ` Joel Fernandes
2023-02-28 11:04 ` Frederic Weisbecker
2023-02-28 20:09 ` Joel Fernandes
2023-03-01 17:11 ` Frederic Weisbecker
2023-03-01 21:31 ` Joel Fernandes
2023-03-02 0:49 ` Paul E. McKenney
2023-03-02 1:08 ` Joel Fernandes
2023-03-02 1:19 ` Paul E. McKenney
2023-02-28 11:42 ` Uladzislau Rezki
2023-02-28 6:40 ` Zhuo, Qiuxu
2023-02-28 14:27 ` Joel Fernandes
2023-03-01 1:34 ` Zhuo, Qiuxu
2023-03-01 15:57 ` Joel Fernandes
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=20230225033421.3323164-1-joel@joelfernandes.org \
--to=joel@joelfernandes.org \
--cc=frederic@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.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
all inboxes | Powered by JetHome®