diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 85b71fbb7531..371bceb23cf2 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6570,6 +6570,18 @@ Force threading of all interrupt handlers except those marked explicitly IRQF_NO_THREAD. + threadprintk [KNL] + Force threaded printing of all legacy consoles. Be + aware that with this option, the shutdown, reboot, and + panic messages may not be printed on the legacy + consoles. Also, earlycon/earlyprintk printing will be + delayed until a regular console or the kthread is + available. + + Users can view /proc/consoles to see if their console + driver is legacy or not. Non-legacy (NBCON) console + drivers are already threaded and are shown with 'N'. + topology= [S390] Format: {off | on} Specify if the kernel should make use of the cpu diff --git a/kernel/printk/internal.h b/kernel/printk/internal.h index b70a2c91a5af..fdf455c89033 100644 --- a/kernel/printk/internal.h +++ b/kernel/printk/internal.h @@ -3,6 +3,7 @@ * internal.h - printk internal definitions */ #include +#include #include #include @@ -24,7 +25,8 @@ int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write, #ifdef CONFIG_PREEMPT_RT # define force_printkthreads() (true) #else -# define force_printkthreads() (false) +DECLARE_STATIC_KEY_FALSE(force_printkthreads_key); +# define force_printkthreads() (static_branch_unlikely(&force_printkthreads_key)) #endif #ifdef CONFIG_PRINTK diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 50e9c3b14ba6..e7ba00d5207a 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -195,6 +195,17 @@ static int __init control_devkmsg(char *str) } __setup("printk.devkmsg=", control_devkmsg); +#if !defined(CONFIG_PREEMPT_RT) +DEFINE_STATIC_KEY_FALSE(force_printkthreads_key); + +static int __init setup_forced_printkthreads(char *arg) +{ + static_branch_enable(&force_printkthreads_key); + return 0; +} +early_param("threadprintk", setup_forced_printkthreads); +#endif + char devkmsg_log_str[DEVKMSG_STR_MAX_SIZE] = "ratelimit"; #if defined(CONFIG_PRINTK) && defined(CONFIG_SYSCTL) int devkmsg_sysctl_set_loglvl(struct ctl_table *table, int write,