linux/include
John Ogness 2bb2b7b57f printk: add functions to prefer direct printing
Once kthread printing is available, console printing will no longer
occur in the context of the printk caller. However, there are some
special contexts where it is desirable for the printk caller to
directly print out kernel messages. Using pr_flush() to wait for
threaded printers is only possible if the caller is in a sleepable
context and the kthreads are active. That is not always the case.

Introduce printk_prefer_direct_enter() and printk_prefer_direct_exit()
functions to explicitly (and globally) activate/deactivate preferred
direct console printing. The term "direct console printing" refers to
printing to all enabled consoles from the context of the printk
caller. The term "prefer" is used because this type of printing is
only best effort. If the console is currently locked or other
printers are already actively printing, the printk caller will need
to rely on the other contexts to handle the printing.

This preferred direct printing is how all printing has been handled
until now (unless it was explicitly deferred).

When kthread printing is introduced, there may be some unanticipated
problems due to kthreads being unable to flush important messages.
In order to minimize such risks, preferred direct printing is
activated for the primary important messages when the system
experiences general types of major errors. These are:

 - emergency reboot/shutdown
 - cpu and rcu stalls
 - hard and soft lockups
 - hung tasks
 - warn
 - sysrq

Note that since kthread printing does not yet exist, no behavior
changes result from this commit. This is only implementing the
counter and marking the various places where preferred direct
printing is active.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Acked-by: Paul E. McKenney <paulmck@kernel.org> # for RCU
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220421212250.565456-13-john.ogness@linutronix.de
2022-04-22 21:30:58 +02:00
..
acpi Merge branches 'acpi-soc', 'acpi-video' and 'acpi-apei' 2022-03-18 17:48:55 +01:00
asm-generic Changes in this cycle were: 2022-03-22 13:44:21 -07:00
clocksource clocksource/drivers/arm_arch_timer: Use event stream scaling when available 2022-03-07 18:27:22 +01:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2022-03-21 16:02:36 -07:00
drm
dt-bindings regulator: Updates for v5.18 2022-03-21 18:27:05 -07:00
keys KEYS: Introduce link restriction for machine keys 2022-03-08 13:55:52 +02:00
kunit
kvm
linux printk: add functions to prefer direct printing 2022-04-22 21:30:58 +02:00
math-emu
media
memory
misc
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf 2022-03-14 15:51:10 -07:00
pcmcia
ras mm/memory-failure.c: fix race with changing page compound again 2022-03-22 15:57:07 -07:00
rdma
scsi scsi: don't use disk->private_data to find the scsi_driver 2022-03-08 19:40:00 -07:00
soc soc: fsl: Replace kernel.h with the necessary inclusions 2022-02-18 17:11:17 -06:00
sound
target
trace Filesystem folio changes for 5.18 2022-03-22 18:26:56 -07:00
uapi Merge branch 'akpm' (patches from Andrew) 2022-03-22 16:11:53 -07:00
vdso
video
xen xen/gnttab: fix gnttab_end_foreign_access() without page specified 2022-03-07 09:48:55 +01:00