* [PATCH v2 0/4] printk: nbcon: deprecate boot_delay in favour of printk_delay
@ 2026-06-30 16:35 Andrew Murray
2026-06-30 16:35 ` [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option Andrew Murray
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Andrew Murray @ 2026-06-30 16:35 UTC (permalink / raw)
To: Jonathan Corbet, Shuah Khan, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Ray Jui, Scott Branden,
Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky,
Andrew Morton, Sebastian Andrzej Siewior, Clark Williams,
Randy Dunlap, Linus Torvalds, Greg Kroah-Hartman
Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-rpi-kernel,
linux-rt-devel, Andrew Murray
The boot_delay (BOOT_PRINTK_DELAY) kernel parameter and printk_delay
sysctl are two distinct mechanisms for providing similar functionality
which add a delay prior to each printed printk message.
boot_delay provides a kernel parameter for delaying printk output from
kernel start through to boot (SYSTEM_RUNNING), whereas printk_delay is
configurable only via sysctl and thus is only used post boot.
However, since the introduction of nbcon and the legacy printer thread
for PREEMPT_RT kernels, printk records are now emited to the console
asynchronously to the caller of printk. Thus, any printk delay added by
boot_delay/printk_delay continues to slow down the calling process but
may not have any impact to the rate in which records are emited to the
console, especially for slow consoles.
To address these issues, let's deprecate boot_delay, extend printk_delay
to be useable from kernel start and ensure that delays occur at the point
where console messages are printed rather than queued.
Please note that this patchset results in delays occuring after a message
is printed rather than, as it is now, before.
Signed-off-by: Andrew Murray <amurray@thegoodpenguin.co.uk>
---
Please see the following related work for additional context:
- https://lore.kernel.org/all/20260503214214.3475670-1-rdunlap@infradead.org/
- https://lore.kernel.org/all/20260505-printk_delay-v1-1-5dba51d7f17c@thegoodpenguin.co.uk/
- https://lore.kernel.org/r/20260601-deprecate_boot_delay-v1-0-c34c187142a6@thegoodpenguin.co.uk (v1)
---
Changes in v2:
- Rebased onto v7.2-rc1
- Correctly handle negative values for printk_delay_msec (patch 2)
- Add missing newline in pr_warn (patch 2)
- Improved patch descriptions for (patches 2 and 3)
- Use new emitted flag in nbcon_context/nbcon_write_context in place of backlog && wctxt.len checks (patch 3)
- Use unsigned char for unsafe_takeover field instead of bool in nbcon_write_context (patch 3)
- Move printk_delay_msec and printk_delay from printk.h to internal.h (patch 3)
- Revert regression added in v1 to __nbcon_atomic_flush_pending_con (patch 3)
- Move printk_delay later in console_emit_next_record ensuring delay is always after emit (across nbcon/legacy) (patch 3)
- Fixed typo in documentation s/boot_delay/printk_delay/g in printk_delay= section (patch 4)
- Link to v1: https://lore.kernel.org/r/20260601-deprecate_boot_delay-v1-0-c34c187142a6@thegoodpenguin.co.uk
---
Andrew Murray (4):
printk: remove BOOT_PRINTK_DELAY config option
printk: deprecate boot_delay in favour of printk_delay
printk: nbcon: move printk_delay to console emiting code
Documentation/kernel-parameters: add/update printk_delay/boot_delay
Documentation/admin-guide/kernel-parameters.txt | 31 +++++++--
arch/arm/configs/bcm2835_defconfig | 1 -
include/linux/console.h | 5 +-
include/linux/printk.h | 1 -
kernel/printk/internal.h | 6 ++
kernel/printk/nbcon.c | 13 ++++
kernel/printk/printk.c | 84 +++++++++++++++----------
lib/Kconfig.debug | 18 ------
8 files changed, 101 insertions(+), 58 deletions(-)
---
base-commit: dc59e4fea9d83f03bad6bddf3fa2e52491777482
change-id: 20260515-deprecate_boot_delay-72516da3845a
Best regards,
--
Andrew Murray <amurray@thegoodpenguin.co.uk>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option
2026-06-30 16:35 [PATCH v2 0/4] printk: nbcon: deprecate boot_delay in favour of printk_delay Andrew Murray
@ 2026-06-30 16:35 ` Andrew Murray
2026-06-30 17:08 ` sashiko-bot
2026-06-30 16:35 ` [PATCH v2 2/4] printk: deprecate boot_delay in favour of printk_delay Andrew Murray
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Andrew Murray @ 2026-06-30 16:35 UTC (permalink / raw)
To: Jonathan Corbet, Shuah Khan, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Ray Jui, Scott Branden,
Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky,
Andrew Morton, Sebastian Andrzej Siewior, Clark Williams,
Randy Dunlap, Linus Torvalds, Greg Kroah-Hartman
Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-rpi-kernel,
linux-rt-devel, Andrew Murray
The boot_delay (BOOT_PRINTK_DELAY) kernel parameter and printk_delay sysctl
are two distinct mechanisms for providing similar functionality which add a
delay prior to each printed printk message.
In preparation of combining them into a single configurable feature, let's
first remove the kconfig option BOOT_PRINTK_DELAY.
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Andrew Murray <amurray@thegoodpenguin.co.uk>
---
Documentation/admin-guide/kernel-parameters.txt | 2 +-
arch/arm/configs/bcm2835_defconfig | 1 -
kernel/printk/printk.c | 2 +-
lib/Kconfig.debug | 18 ------------------
4 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b5493a7f8f22812833308b22f2cc35b0a42e55b2..2884103b93bca7b76cd3a93946276074cf62d0a1 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -651,7 +651,7 @@ Kernel parameters
boot_delay= [KNL,EARLY]
Milliseconds to delay each printk during boot.
- Only works if CONFIG_BOOT_PRINTK_DELAY is enabled,
+ Only works if GENERIC_CALIBRATE_DELAY is enabled,
and you may also have to specify "lpj=". Boot_delay
values larger than 10 seconds (10000) are assumed
erroneous and ignored.
diff --git a/arch/arm/configs/bcm2835_defconfig b/arch/arm/configs/bcm2835_defconfig
index 4a8ac09843d73280cc42dbbf63fe3cc9f31dacd2..51a1e94d5aa6c22202778082b877a202a6b9c04d 100644
--- a/arch/arm/configs/bcm2835_defconfig
+++ b/arch/arm/configs/bcm2835_defconfig
@@ -174,7 +174,6 @@ CONFIG_NLS_UTF8=y
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=32
CONFIG_PRINTK_TIME=y
-CONFIG_BOOT_PRINTK_DELAY=y
CONFIG_DYNAMIC_DEBUG=y
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
# CONFIG_ENABLE_MUST_CHECK is not set
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 2fe9a963c823a41e7df10c29939a2abb55462859..77f53eaed13216c6c3946adabc0c8fdba6401d91 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1289,7 +1289,7 @@ static bool suppress_message_printing(int level)
return (level >= console_loglevel && !ignore_loglevel);
}
-#ifdef CONFIG_BOOT_PRINTK_DELAY
+#ifdef CONFIG_GENERIC_CALIBRATE_DELAY
static int boot_delay; /* msecs delay after each printk during bootup */
static unsigned long long loops_per_msec; /* based on boot_delay */
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 1244dcac2294ad99fda37fa6767c9e76f16a4d14..b552ea51cd53b79cf5d58b8c4deff409b1982862 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -99,24 +99,6 @@ config MESSAGE_LOGLEVEL_DEFAULT
by default. To change that, use loglevel=<x> in the kernel bootargs,
or pick a different CONSOLE_LOGLEVEL_DEFAULT configuration value.
-config BOOT_PRINTK_DELAY
- bool "Delay each boot printk message by N milliseconds"
- depends on DEBUG_KERNEL && PRINTK && GENERIC_CALIBRATE_DELAY
- help
- This build option allows you to read kernel boot messages
- by inserting a short delay after each one. The delay is
- specified in milliseconds on the kernel command line,
- using "boot_delay=N".
-
- It is likely that you would also need to use "lpj=M" to preset
- the "loops per jiffy" value.
- See a previous boot log for the "lpj" value to use for your
- system, and then set "lpj=M" before setting "boot_delay=N".
- NOTE: Using this option may adversely affect SMP systems.
- I.e., processors other than the first one may not boot up.
- BOOT_PRINTK_DELAY also may cause LOCKUP_DETECTOR to detect
- what it believes to be lockup conditions.
-
config DYNAMIC_DEBUG
bool "Enable dynamic printk() support"
default n
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/4] printk: deprecate boot_delay in favour of printk_delay
2026-06-30 16:35 [PATCH v2 0/4] printk: nbcon: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-06-30 16:35 ` [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option Andrew Murray
@ 2026-06-30 16:35 ` Andrew Murray
2026-06-30 16:49 ` sashiko-bot
2026-06-30 16:35 ` [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code Andrew Murray
2026-06-30 16:36 ` [PATCH v2 4/4] Documentation/kernel-parameters: add/update printk_delay/boot_delay Andrew Murray
3 siblings, 1 reply; 8+ messages in thread
From: Andrew Murray @ 2026-06-30 16:35 UTC (permalink / raw)
To: Jonathan Corbet, Shuah Khan, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Ray Jui, Scott Branden,
Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky,
Andrew Morton, Sebastian Andrzej Siewior, Clark Williams,
Randy Dunlap, Linus Torvalds, Greg Kroah-Hartman
Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-rpi-kernel,
linux-rt-devel, Andrew Murray
The boot_delay (BOOT_PRINTK_DELAY) kernel parameter and printk_delay sysctl
are two distinct mechanisms for providing similar functionality which add a
delay prior to each printed printk message.
boot_delay provides a kernel parameter for delaying printk output from
kernel start through to boot (SYSTEM_RUNNING), whereas printk_delay is
configurable only via sysctl and thus is only used post boot.
Let's deprecate the boot_delay feature in favour of printk_delay. In order
to preserve functionality, we'll also extend printk_delay such that it can
additionally configured via an early kernel parameter.
Behavior change:
The delay enabled by both "boot_delay" and "printk_delay" continues
working even in SYSTEM_RUNNING state. It must be explicitly stopped
by setting printk_delay=0 via sysctl.
The delay is skipped when the message is suppressed in all system
states. It used to skipped only for the boot_delay.
Signed-off-by: Andrew Murray <amurray@thegoodpenguin.co.uk>
---
kernel/printk/printk.c | 77 ++++++++++++++++++++++++++++++++------------------
1 file changed, 49 insertions(+), 28 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 77f53eaed13216c6c3946adabc0c8fdba6401d91..cc203327247aa4f81f55b907c66ac88f30ce6da8 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1291,40 +1291,28 @@ static bool suppress_message_printing(int level)
#ifdef CONFIG_GENERIC_CALIBRATE_DELAY
-static int boot_delay; /* msecs delay after each printk during bootup */
static unsigned long long loops_per_msec; /* based on boot_delay */
-static int __init boot_delay_setup(char *str)
+static void __init printk_delay_calculate(void)
{
unsigned long lpj;
lpj = preset_lpj ? preset_lpj : 1000000; /* some guess */
loops_per_msec = (unsigned long long)lpj / 1000 * HZ;
- get_option(&str, &boot_delay);
- if (boot_delay > 10 * 1000)
- boot_delay = 0;
-
- pr_debug("boot_delay: %u, preset_lpj: %ld, lpj: %lu, "
+ pr_debug("printk_delay: %u, preset_lpj: %ld, lpj: %lu, "
"HZ: %d, loops_per_msec: %llu\n",
- boot_delay, preset_lpj, lpj, HZ, loops_per_msec);
- return 0;
+ printk_delay_msec, preset_lpj, lpj, HZ, loops_per_msec);
}
-early_param("boot_delay", boot_delay_setup);
-static void boot_delay_msec(int level)
+static void early_boot_delay_msec(void)
{
unsigned long long k;
unsigned long timeout;
- bool suppress = !is_printk_force_console() &&
- suppress_message_printing(level);
-
- if ((boot_delay == 0 || system_state >= SYSTEM_RUNNING) || suppress)
- return;
- k = (unsigned long long)loops_per_msec * boot_delay;
+ k = (unsigned long long)loops_per_msec * printk_delay_msec;
- timeout = jiffies + msecs_to_jiffies(boot_delay);
+ timeout = jiffies + msecs_to_jiffies(printk_delay_msec);
while (k) {
k--;
cpu_relax();
@@ -1339,11 +1327,34 @@ static void boot_delay_msec(int level)
}
}
#else
-static inline void boot_delay_msec(int level)
+static inline void __init printk_delay_calculate(void)
+{
+}
+
+static inline void early_boot_delay_msec(void)
{
}
#endif
+static int __init printk_delay_setup(char *str)
+{
+ get_option(&str, &printk_delay_msec);
+ if (printk_delay_msec > 10 * 1000)
+ printk_delay_msec = 0;
+
+ printk_delay_calculate();
+
+ return 0;
+}
+early_param("printk_delay", printk_delay_setup);
+
+static int __init boot_delay_setup(char *str)
+{
+ pr_warn("boot_delay will soon be deprecated, please use printk_delay instead\n");
+ return printk_delay_setup(str);
+}
+early_param("boot_delay", boot_delay_setup);
+
static bool printk_time = IS_ENABLED(CONFIG_PRINTK_TIME);
module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
@@ -2117,20 +2128,30 @@ static u8 *__printk_recursion_counter(void)
local_irq_restore(flags); \
} while (0)
-int printk_delay_msec __read_mostly;
+unsigned int printk_delay_msec __read_mostly;
+
+static inline void late_boot_delay_msec(void)
+{
+ unsigned int m = printk_delay_msec;
+
+ while (m--) {
+ mdelay(1);
+ touch_nmi_watchdog();
+ }
+}
static inline void printk_delay(int level)
{
- boot_delay_msec(level);
+ bool suppress = !is_printk_force_console() &&
+ suppress_message_printing(level);
- if (unlikely(printk_delay_msec)) {
- int m = printk_delay_msec;
+ if (likely(!printk_delay_msec) || suppress)
+ return;
- while (m--) {
- mdelay(1);
- touch_nmi_watchdog();
- }
- }
+ if (system_state < SYSTEM_RUNNING)
+ early_boot_delay_msec();
+ else
+ late_boot_delay_msec();
}
#define CALLER_ID_MASK 0x80000000
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code
2026-06-30 16:35 [PATCH v2 0/4] printk: nbcon: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-06-30 16:35 ` [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option Andrew Murray
2026-06-30 16:35 ` [PATCH v2 2/4] printk: deprecate boot_delay in favour of printk_delay Andrew Murray
@ 2026-06-30 16:35 ` Andrew Murray
2026-06-30 17:09 ` sashiko-bot
2026-06-30 16:36 ` [PATCH v2 4/4] Documentation/kernel-parameters: add/update printk_delay/boot_delay Andrew Murray
3 siblings, 1 reply; 8+ messages in thread
From: Andrew Murray @ 2026-06-30 16:35 UTC (permalink / raw)
To: Jonathan Corbet, Shuah Khan, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Ray Jui, Scott Branden,
Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky,
Andrew Morton, Sebastian Andrzej Siewior, Clark Williams,
Randy Dunlap, Linus Torvalds, Greg Kroah-Hartman
Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-rpi-kernel,
linux-rt-devel, Andrew Murray
The printk_delay and boot_delay features are helpful for debugging
as kernel output can be slowed down during boot allowing messages to
be seen before scrolling off the screen, or to correlate timing between
some physical event and console output.
However, since the introduction of nbcon and the legacy printer thread
for PREEMPT_RT kernels, printk records are now emited to the console
asynchronously to the caller of printk. Thus, any printk delay added by
boot_delay/printk_delay continues to slow down the calling process but
may not have any impact to the rate in which records are emited to the
console.
Let's address this by moving the printk delay from the calling code
to the console emiting code instead. Whilst this ensures that delays
are still observed (especially for slower consoles), it doesn't improve
the use-case of using boot_delay/printk_delay to correlate timings
between physical events and console output.
Behavior change:
Please note that printk delays now occur after messages are emitted
rather than before.
Signed-off-by: Andrew Murray <amurray@thegoodpenguin.co.uk>
---
include/linux/console.h | 5 ++++-
include/linux/printk.h | 1 -
kernel/printk/internal.h | 6 ++++++
kernel/printk/nbcon.c | 13 +++++++++++++
kernel/printk/printk.c | 15 +++++++--------
5 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/include/linux/console.h b/include/linux/console.h
index d624200cfc1708bf73925892a466efe0c95c5586..3478b556c0eb9579530409dc6fbb9b5a8bff581c 100644
--- a/include/linux/console.h
+++ b/include/linux/console.h
@@ -290,6 +290,8 @@ struct nbcon_context {
* @outbuf: Pointer to the text buffer for output
* @len: Length to write
* @unsafe_takeover: If a hostile takeover in an unsafe state has occurred
+ * @emitted: The write context attempted to emit the message. Might
+ * be incomplete.
* @cpu: CPU on which the message was generated
* @pid: PID of the task that generated the message
* @comm: Name of the task that generated the message
@@ -298,7 +300,8 @@ struct nbcon_write_context {
struct nbcon_context __private ctxt;
char *outbuf;
unsigned int len;
- bool unsafe_takeover;
+ unsigned char unsafe_takeover : 1;
+ unsigned char emitted : 1;
#ifdef CONFIG_PRINTK_EXECUTION_CTX
int cpu;
pid_t pid;
diff --git a/include/linux/printk.h b/include/linux/printk.h
index f594c1266bfd411f2238b45374e8a71222f0407c..8885e11367d50ea1cd7642249852d011e589adb4 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -188,7 +188,6 @@ extern int __printk_ratelimit(const char *func);
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
unsigned int interval_msec);
-extern int printk_delay_msec;
extern int dmesg_restrict;
extern void wake_up_klogd(void);
diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h
index 85fbf1801cbe070ad96d253bccdf775a11bf945a..c3586f8b8360208902bbbd4607413997bcbd5fb9 100644
--- a/kernel/printk/internal.h
+++ b/kernel/printk/internal.h
@@ -33,6 +33,8 @@ int devkmsg_sysctl_set_loglvl(const struct ctl_table *table, int write,
# define force_legacy_kthread() (false)
#endif
+extern unsigned int printk_delay_msec;
+
#ifdef CONFIG_PRINTK
#ifdef CONFIG_PRINTK_CALLER
@@ -131,6 +133,8 @@ static inline void nbcon_kthread_wake(struct console *con)
rcuwait_wake_up(&con->rcuwait); /* LMM(nbcon_kthread_wake:A) */
}
+void printk_delay(bool use_atomic);
+
#else
#define PRINTK_PREFIX_MAX 0
@@ -162,6 +166,8 @@ static inline bool nbcon_legacy_emit_next_record(struct console *con, bool *hand
static inline void nbcon_kthread_wake(struct console *con) { }
static inline void nbcon_kthreads_wake(void) { }
+static inline void printk_delay(bool use_atomic) { }
+
#endif /* CONFIG_PRINTK */
extern bool have_boot_console;
diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
index 4b03b019cd5ee25d68e9ace84392045e91241a7f..ae45cb0589c0effafc66f1756bdaecd1c1e53ab9 100644
--- a/kernel/printk/nbcon.c
+++ b/kernel/printk/nbcon.c
@@ -1069,6 +1069,8 @@ static bool nbcon_emit_next_record(struct nbcon_write_context *wctxt, bool use_a
else
con->write_thread(con, wctxt);
+ wctxt->emitted = 1;
+
if (!wctxt->outbuf) {
/*
* Ownership was lost and reacquired by the driver. Handle it
@@ -1267,11 +1269,16 @@ static int nbcon_kthread_func(void *__console)
con_flags = console_srcu_read_flags(con);
+ wctxt.emitted = 0;
+
if (console_is_usable(con, con_flags, false))
backlog = nbcon_emit_one(&wctxt, false);
console_srcu_read_unlock(cookie);
+ if (backlog && wctxt.emitted)
+ printk_delay(false);
+
cond_resched();
} while (backlog);
@@ -1525,6 +1532,8 @@ bool nbcon_legacy_emit_next_record(struct console *con, bool *handover,
}
progress = nbcon_emit_one(&wctxt, use_atomic);
+ if (progress && wctxt.emitted)
+ printk_delay(use_atomic);
if (use_atomic) {
start_critical_timings();
@@ -1584,6 +1593,8 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq)
if (!nbcon_context_try_acquire(ctxt, false))
return -EPERM;
+ wctxt.emitted = 0;
+
/*
* nbcon_emit_next_record() returns false when
* the console was handed over or taken over.
@@ -1600,6 +1611,8 @@ static int __nbcon_atomic_flush_pending_con(struct console *con, u64 stop_seq)
if (nbcon_seq_read(con) < stop_seq)
err = -ENOENT;
break;
+ } else if (wctxt.emitted > 0) {
+ printk_delay(true);
}
}
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index cc203327247aa4f81f55b907c66ac88f30ce6da8..5278d9cb19e4177a00998fba5c1438251e033578 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2140,18 +2140,17 @@ static inline void late_boot_delay_msec(void)
}
}
-static inline void printk_delay(int level)
+void printk_delay(bool use_atomic)
{
- bool suppress = !is_printk_force_console() &&
- suppress_message_printing(level);
-
- if (likely(!printk_delay_msec) || suppress)
+ if (likely(!printk_delay_msec))
return;
if (system_state < SYSTEM_RUNNING)
early_boot_delay_msec();
- else
+ else if (use_atomic)
late_boot_delay_msec();
+ else
+ msleep(printk_delay_msec);
}
#define CALLER_ID_MASK 0x80000000
@@ -2471,8 +2470,6 @@ asmlinkage int vprintk_emit(int facility, int level,
ft.legacy_direct = false;
}
- printk_delay(level);
-
printed_len = vprintk_store(facility, level, dev_info, fmt, args);
if (ft.nbcon_atomic)
@@ -3211,6 +3208,8 @@ static bool console_emit_next_record(struct console *con, bool *handover, int co
*handover = console_lock_spinning_disable_and_check(cookie);
printk_safe_exit_irqrestore(flags);
}
+ printk_delay(true);
+
skip:
return true;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/4] Documentation/kernel-parameters: add/update printk_delay/boot_delay
2026-06-30 16:35 [PATCH v2 0/4] printk: nbcon: deprecate boot_delay in favour of printk_delay Andrew Murray
` (2 preceding siblings ...)
2026-06-30 16:35 ` [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code Andrew Murray
@ 2026-06-30 16:36 ` Andrew Murray
3 siblings, 0 replies; 8+ messages in thread
From: Andrew Murray @ 2026-06-30 16:36 UTC (permalink / raw)
To: Jonathan Corbet, Shuah Khan, Russell King, Florian Fainelli,
Broadcom internal kernel review list, Ray Jui, Scott Branden,
Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky,
Andrew Morton, Sebastian Andrzej Siewior, Clark Williams,
Randy Dunlap, Linus Torvalds, Greg Kroah-Hartman
Cc: linux-doc, linux-kernel, linux-arm-kernel, linux-rpi-kernel,
linux-rt-devel, Andrew Murray
boot_delay has been deprecated in favour of an extended printk_delay,
let's update kernel-parameters to reflect the addition of printk_delay
and the deprecation of boot_delay.
Reviewed-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Andrew Murray <amurray@thegoodpenguin.co.uk>
---
Documentation/admin-guide/kernel-parameters.txt | 31 +++++++++++++++++++++----
1 file changed, 26 insertions(+), 5 deletions(-)
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 2884103b93bca7b76cd3a93946276074cf62d0a1..1118feda87b1b04543b1da0bd52c090b1fddaeac 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -650,11 +650,19 @@ Kernel parameters
See Documentation/block/cmdline-partition.rst
boot_delay= [KNL,EARLY]
- Milliseconds to delay each printk during boot.
- Only works if GENERIC_CALIBRATE_DELAY is enabled,
- and you may also have to specify "lpj=". Boot_delay
- values larger than 10 seconds (10000) are assumed
- erroneous and ignored.
+ Milliseconds to delay each printk during and post boot.
+ Boot time delays only work if GENERIC_CALIBRATE_DELAY
+ is enabled.
+
+ Once booted the delay can be removed or adjusted via
+ the printk_delay sysctl.
+
+ Please note that you may also have to specify "lpj=".
+ Boot_delay values larger than 10 seconds (10000) are
+ assumed erroneous and ignored.
+
+ This will soon be deprecated, please use printk_delay
+ instead.
Format: integer
bootconfig [KNL,EARLY]
@@ -5468,6 +5476,19 @@ Kernel parameters
printk.time= Show timing data prefixed to each printk message line
Format: <bool> (1/Y/y=enable, 0/N/n=disable)
+ printk_delay= [KNL,EARLY]
+ Milliseconds to delay each printk during and post boot.
+ Boot time delays only work if GENERIC_CALIBRATE_DELAY
+ is enabled.
+
+ Once booted the delay can be removed or adjusted via
+ the printk_delay sysctl.
+
+ Please note that you may also have to specify "lpj=".
+ printk_delay values larger than 10 seconds (10000) are
+ assumed erroneous and ignored.
+ Format: integer
+
proc_mem.force_override= [KNL]
Format: {always | ptrace | never}
Traditionally /proc/pid/mem allows memory permissions to be
--
2.34.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/4] printk: deprecate boot_delay in favour of printk_delay
2026-06-30 16:35 ` [PATCH v2 2/4] printk: deprecate boot_delay in favour of printk_delay Andrew Murray
@ 2026-06-30 16:49 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-06-30 16:49 UTC (permalink / raw)
To: Andrew Murray; +Cc: linux-kernel, linux-rt-devel
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Sysctl handler `proc_dointvec_minmax` is incorrectly used for an `unsigned int` variable.
- [Low] Passing an incompatible pointer type (`unsigned int *`) to `get_option()`, which expects an `int *`.
--
commit 75c913a5c205c791c2728e8990c05d9b6634f1b5
Author: Andrew Murray <amurray@thegoodpenguin.co.uk>
printk: deprecate boot_delay in favour of printk_delay
This commit deprecates the boot_delay kernel parameter in favor of
printk_delay. It extends printk_delay to be configurable via an early
kernel parameter, allowing it to function during both boot and runtime.
The delay is now skipped when messages are suppressed across all system
states.
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 77f53eaed1321..cc203327247aa 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
[ ... ]
> @@ -1339,11 +1327,34 @@ static void boot_delay_msec(int level)
> }
> }
> #else
> -static inline void boot_delay_msec(int level)
> +static inline void __init printk_delay_calculate(void)
> {
> }
>
> +static inline void early_boot_delay_msec(void)
> {
> }
> #endif
>
> +static int __init printk_delay_setup(char *str)
> +{
> + get_option(&str, &printk_delay_msec);
[Severity: Low]
Does this pointer sign mismatch introduce a build regression?
The get_option() function expects an int * for its second argument, but
printk_delay_msec was changed to an unsigned int in this patch. This triggers
a -Wincompatible-pointer-types warning, which is often treated as an error by
modern compilers.
[ ... ]
> @@ -2117,20 +2128,30 @@ static u8 *__printk_recursion_counter(void)
> local_irq_restore(flags); \
> } while (0)
>
> -int printk_delay_msec __read_mostly;
> +unsigned int printk_delay_msec __read_mostly;
[Severity: Low]
Is the sysctl handler for printk_delay_msec still correct?
In kernel/printk/sysctl.c, the sysctl entry for printk_delay_msec uses
the proc_dointvec_minmax handler, which expects a pointer to a signed int.
Since printk_delay_msec is now an unsigned int, should this be updated to
proc_douintvec_minmax to prevent an API regression?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630-deprecate_boot_delay-v2-0-f9883d36aa4b@thegoodpenguin.co.uk?part=2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option
2026-06-30 16:35 ` [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option Andrew Murray
@ 2026-06-30 17:08 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-06-30 17:08 UTC (permalink / raw)
To: Andrew Murray; +Cc: linux-rt-devel, linux-kernel
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The kernel command line parameter `boot_delay` can be parsed as a negative integer, which causes a massive integer underflow and a near-infinite loop, resulting in a boot hang.
--
commit 7ede3add142d62f673ea88e35c108d0ec8e7599d
Author: Andrew Murray <amurray@thegoodpenguin.co.uk>
printk: remove BOOT_PRINTK_DELAY config option
The boot_delay (BOOT_PRINTK_DELAY) kernel parameter and printk_delay sysctl
are two distinct mechanisms for providing similar functionality which add a
delay prior to each printed printk message. This commit prepares to combine
them by removing the BOOT_PRINTK_DELAY kconfig option.
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 2fe9a963c823a..77f53eaed1321 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -1289,7 +1289,7 @@ static bool suppress_message_printing(int level)
> return (level >= console_loglevel && !ignore_loglevel);
> }
>
> -#ifdef CONFIG_BOOT_PRINTK_DELAY
> +#ifdef CONFIG_GENERIC_CALIBRATE_DELAY
>
> static int boot_delay; /* msecs delay after each printk during bootup */
> static unsigned long long loops_per_msec; /* based on boot_delay */
[Severity: High]
This is a pre-existing issue, but does expanding the availability of the
boot_delay parameter expose a potential boot hang if a negative value is
provided on the kernel command line?
When boot_delay is parsed in boot_delay_setup(), the bounds check does not
reject negative inputs:
kernel/printk/printk.c:boot_delay_setup() {
...
get_option(&str, &boot_delay);
if (boot_delay > 10 * 1000)
boot_delay = 0;
...
}
If a user provides a negative value like boot_delay=-1, could
boot_delay_msec() cast this negative integer to an unsigned type, resulting
in an immense timeout?
kernel/printk/printk.c:boot_delay_msec() {
...
k = (unsigned long long)loops_per_msec * boot_delay;
timeout = jiffies + msecs_to_jiffies(boot_delay);
...
}
Because msecs_to_jiffies() casts the negative value to an unsigned int, this
could result in spinning in cpu_relax() almost indefinitely.
Might it be safer to add a check in boot_delay_setup() to ensure boot_delay
is not less than zero?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630-deprecate_boot_delay-v2-0-f9883d36aa4b@thegoodpenguin.co.uk?part=1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code
2026-06-30 16:35 ` [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code Andrew Murray
@ 2026-06-30 17:09 ` sashiko-bot
0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-06-30 17:09 UTC (permalink / raw)
To: Andrew Murray; +Cc: linux-kernel, linux-rt-devel
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
New issues:
- [High] `printk_delay(use_atomic)` causes massive IRQ latency by busy-waiting with local interrupts disabled in `nbcon_legacy_emit_next_record()`.
- [Medium] `printk_delay()` bypasses its intended rate-limiting function when a console lock handover occurs in `console_emit_next_record()`.
- [Medium] Moving `printk_delay()` into the console flush loops incorrectly multiplies the delay by the number of active consoles.
Pre-existing issues:
- [Critical] Use-after-free of the `con` pointer in `console_flush_all()` due to an expanded race window when `printk_delay()` is called.
--
commit e90407202970d9d83dc93dd60ca58eb802e88311
Author: Andrew Murray <amurray@thegoodpenguin.co.uk>
printk: nbcon: move printk_delay to console emiting code
This commit moves the printk delay from the caller of printk to the
console emitting code. This ensures delays are observed even when
messages are emitted asynchronously to the console.
> diff --git a/kernel/printk/nbcon.c b/kernel/printk/nbcon.c
> --- a/kernel/printk/nbcon.c
> +++ b/kernel/printk/nbcon.c
[ ... ]
> @@ -1525,6 +1532,8 @@ bool nbcon_legacy_emit_next_record(struct console *con, bool *handover,
> }
>
> progress = nbcon_emit_one(&wctxt, use_atomic);
> + if (progress && wctxt.emitted)
> + printk_delay(use_atomic);
[Severity: High]
Does calling printk_delay() here cause massive IRQ latency?
In nbcon_legacy_emit_next_record(), when use_atomic is true, local
interrupts are explicitly disabled via printk_safe_enter_irqsave() just
before this block:
if (use_atomic) {
printk_safe_enter_irqsave(flags);
console_lock_spinning_enable();
stop_critical_timings();
}
Calling printk_delay(use_atomic) while IRQs are disabled will execute
late_boot_delay_msec() which busy-loops.
Could this stall the CPU with interrupts disabled for hundreds of
milliseconds per message, potentially dropping hardware interrupts or
triggering the NMI watchdog?
> if (use_atomic) {
> start_critical_timings();
[ ... ]
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
[ ... ]
> @@ -3211,6 +3208,8 @@ static bool console_emit_next_record(struct console *con, bool *handover, int co
> *handover = console_lock_spinning_disable_and_check(cookie);
> printk_safe_exit_irqrestore(flags);
> }
> + printk_delay(true);
> +
[Severity: Critical]
This isn't a bug introduced by this patch, but does the expanded delay
create a use-after-free window for the con pointer in console_flush_all()?
In console_emit_next_record(), if a lock handover occurs,
console_lock_spinning_disable_and_check() releases the SRCU read lock.
This patch inserts printk_delay(true) immediately after this lock release,
adding a multi-millisecond busy-wait delay.
During this expanded window, another CPU can unregister and free the console
because the SRCU lock is no longer held.
When console_emit_next_record() returns to console_flush_all(), it
unconditionally dereferences con->seq before checking if a handover occurred:
if (!console_emit_next_record(con, &handover, cookie))
continue;
printk_seq = con->seq;
Could this massive delay guarantee a use-after-free if a console is
unregistered under contention?
[Severity: Medium]
Also regarding this delay placement, if a console lock handover occurs,
is the intended rate limiting bypassed?
When multiple CPUs attempt to print, console_lock_spinning_disable_and_check()
yields the lock to a waiting CPU before the delay begins.
The waiting CPU will immediately acquire the lock and begin printing the next
message without waiting for the first CPU's delay to finish.
Does this result in messages being emitted in an immediate burst under lock
contention, bypassing the intended pacing?
[Severity: Medium]
Additionally, does moving printk_delay() here multiply the delay by the
number of active consoles?
Previously, vprintk_emit() called printk_delay() once per message.
Because console_emit_next_record() is called sequentially for each registered
console within the for_each_console_srcu(con) loop in console_flush_all():
for_each_console_srcu(con) {
...
if (!console_emit_next_record(con, &handover, cookie))
continue;
...
}
Will the delay now be executed N times per message, where N is the number of
active consoles?
> skip:
> return true;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630-deprecate_boot_delay-v2-0-f9883d36aa4b@thegoodpenguin.co.uk?part=3
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-06-30 17:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 16:35 [PATCH v2 0/4] printk: nbcon: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-06-30 16:35 ` [PATCH v2 1/4] printk: remove BOOT_PRINTK_DELAY config option Andrew Murray
2026-06-30 17:08 ` sashiko-bot
2026-06-30 16:35 ` [PATCH v2 2/4] printk: deprecate boot_delay in favour of printk_delay Andrew Murray
2026-06-30 16:49 ` sashiko-bot
2026-06-30 16:35 ` [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code Andrew Murray
2026-06-30 17:09 ` sashiko-bot
2026-06-30 16:36 ` [PATCH v2 4/4] Documentation/kernel-parameters: add/update printk_delay/boot_delay Andrew Murray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox