mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6 v2] printk: Cleanups and softlockup avoidance
@ 2014-03-13 15:58 Jan Kara
  2014-03-13 15:58 ` [PATCH 1/6] printk: Remove outdated comment Jan Kara
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Jan Kara @ 2014-03-13 15:58 UTC (permalink / raw)
  To: Andrew Morton
  Cc: LKML, pmladek, Steven Rostedt, Frederic Weisbecker, Jan Kara

  Hello,

  this is another piece of the printk softlockup saga series. Let me first
remind the problem:

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 below).

The patch set is organized as follows:

Patch 1 is just a cleanup which can be taken on its own (a result of my
research in kernel history ;).

Patches 2 and 3 change vprintk_emit() to call console_unlock() with interrupts
enabled so they help to reduce interrupt latency in common case when printk()
itself is called with interrupts enabled.

Patch 4 is a cleanup of printk_sched() facility from Steven.

Patch 5 is the meat of this series implementing passing of printing duty from
current CPU after printing printk.offload_chars. We wake up a kthread which
starts spinning on console_sem to take over printing.

Patch 6 fixes lockups in one situation which I hit in my testing - if someone
calls stop_machine(), handing over of printing stops working (see commit
message for details). If you find this too hacky, I'm ok with dropping this
patch at least for now because I'm not sure this problem can be hit without
artificially stressing the machine.

What do you guys think?

						Merry Christmas ;)
								Honza

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-03-14 13:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-13 15:58 [PATCH 0/6 v2] printk: Cleanups and softlockup avoidance Jan Kara
2014-03-13 15:58 ` [PATCH 1/6] printk: Remove outdated comment Jan Kara
2014-03-13 15:58 ` [PATCH 2/6] printk: Release lockbuf_lock before calling console_trylock_for_printk() Jan Kara
2014-03-13 15:58 ` [PATCH 3/6] printk: Enable interrupts " Jan Kara
2014-03-13 15:58 ` [PATCH 4/6] printk: Remove separate printk_sched buffers and use printk buf instead Jan Kara
2014-03-13 15:58 ` [PATCH 5/6] printk: Hand over printing to console if printing too long Jan Kara
2014-03-13 23:06   ` Andrew Morton
2014-03-13 23:26     ` One Thousand Gnomes
2014-03-14 12:26       ` Jan Kara
2014-03-14 13:00     ` Jan Kara
2014-03-14 13:30     ` Jan Kara
2014-03-13 15:58 ` [PATCH 6/6] kernel: Avoid softlockups in stop_machine() during heavy printing Jan Kara
2014-03-13 23:09   ` Andrew Morton

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®