Skip to content

printk: Cleanups and softlockup avoidance

Jan Kara lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest8 patches 20 repliesIn review
  2. v38 patches 0 repliesSuperseded
  3. v26 patches 6 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v19 patches18 repliesApplied

Changes in v4 from the cover letter

Fixed bogus warning in console_try_lock_spin() in non-preemptible kernels. Fixed infinite loop in console_flush() when console was suspended.

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8printk: Remove outdated commentkernel/printk/printk.c+1 -20 replies
2/8printk: Release lockbuf_lock before calling console_trylock_for_printk()kernel/printk/printk.c+17 -322 replies
3/8printk: Enable interrupts before calling console_trylock_for_printk()kernel/printk/printk.c+18 -110 replies
4/8printk: Remove separate printk_sched buffers and use printk buf insteadkernel/printk/printk.c+29 -181 reply
5/8printk: Hand over printing to console if printing too longDocumentation/kernel-parameters.txt kernel/printk/printk.c+194 -170 replies
6/8printk: Start printing handover kthreads on demandkernel/printk/printk.c+50 -142 replies
7/8kernel: Avoid softlockups in stop_machine() during heavy printinginclude/linux/console.h kernel/printk/printk.c kernel/stop_machine.c+32 -00 replies
8/8printk: Add config option for disabling printk offloadingDocumentation/kernel-parameters.txt init/Kconfig kernel/printk/printk.c+35 -613 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.

Read the v4 thread

Cover letter [PATCH 0/8 v4] printk: Cleanups and softlockup avoidance

Hello,

this is another revision of the printk softlockup series.

Changes since v3:
Fixed bogus warning in console_try_lock_spin() in non-preemptible kernels. Fixed infinite loop in console_flush() when console was suspended.

Changes since v2:
I have fixed up some small problems pointed out by Andrew, added possibility to configure out the printk offloading logic (for small systems), and offload kthreads are now started only once printk.offload_chars is set to value > 0.

Intro for the newcomers to the series below.

---

Currently, console_unlock() prints messages from kernel printk buffer to console while the buffer is non-empty. When serial console is attached, printing is slow and thus other CPUs in the system have plenty of time to append new messages to the buffer while one CPU is printing. Thus the CPU can spend unbounded amount of time doing printing in console_unlock(). This is especially serious since vprintk_emit() calls console_unlock() with interrupts disabled.

In practice users have observed a CPU can spend tens of seconds printing in console_unlock() (usually during boot when hundreds of SCSI devices are discovered) resulting in RCU stalls (CPU doing printing doesn't reach quiescent state for a long time), softlockup reports (IPIs for the printing CPU don't get served and thus other CPUs are spinning waiting for the printing CPU to process IPIs), and eventually a machine death (as messages from stalls and lockups append to printk buffer faster than we are able to print). So these machines are unable to boot with serial console attached. Also during artificial stress testing SATA disk disappears from the system because its interrupts aren't served for too long.

This is a revised series using my new approach to the problem which doesn't let CPU out of console_unlock() until there's someone else to take over the printing. The main difference since the last version is that instead of passing printing duty to different CPUs via IPIs we use dedicated kthreads. This method is somewhat less reliable (in a sense that there are more situations in which handover needn't work at all - e.g. when the currently printing CPU holds a spinlock and the CPU where kthread is scheduled to run is spinning on this spinlock) but the code is much simpler and in my practical testing kthread approach was good enough to avoid any problems (with one exception - see patch 8/8).

Honza