Files
Linux/include/linux
Tejun Heo 8d91f8b153 printk: do cond_resched() between lines while outputting to consoles
@console_may_schedule tracks whether console_sem was acquired through
lock or trylock.  If the former, we're inside a sleepable context and
console_conditional_schedule() performs cond_resched().  This allows
console drivers which use console_lock for synchronization to yield
while performing time-consuming operations such as scrolling.

However, the actual console outputting is performed while holding
irq-safe logbuf_lock, so console_unlock() clears @console_may_schedule
before starting outputting lines.  Also, only a few drivers call
console_conditional_schedule() to begin with.  This means that when a
lot of lines need to be output by console_unlock(), for example on a
console registration, the task doing console_unlock() may not yield for
a long time on a non-preemptible kernel.

If this happens with a slow console devices, for example a serial
console, the outputting task may occupy the cpu for a very long time.
Long enough to trigger softlockup and/or RCU stall warnings, which in
turn pile more messages, sometimes enough to trigger the next cycle of
warnings incapacitating the system.

Fix it by making console_unlock() insert cond_resched() between lines if
@console_may_schedule.

Signed-off-by: Tejun Heo <[email protected]>
Reported-by: Calvin Owens <[email protected]>
Acked-by: Jan Kara <[email protected]>
Cc: Dave Jones <[email protected]>
Cc: Kyle McMartin <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
2016-01-16 11:17:25 -08:00
..
…
…
…
…
…
…
…
…
…
2016-01-11 17:48:53 -05:00
2016-01-05 18:04:58 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
…
…
2015-12-06 12:46:31 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2015-12-28 13:41:50 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
2015-12-14 10:03:46 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
2016-01-15 17:56:32 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
…
…
…
…
…
…
…
…
…
2015-12-04 22:46:26 +01:00
…
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-04 13:19:55 -05:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
…
…
…
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
…
2016-01-07 14:31:27 -05:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
…
…
…
…
…
2016-01-10 22:13:15 -05:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2015-12-13 19:59:48 -08:00
…
…
…
…
…
2016-01-04 16:11:11 -05:00
…
…
…
…
2016-01-14 16:00:49 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2016-01-04 10:20:19 -05:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
2015-12-21 15:28:11 -07:00
…
…
…
…
…
…
2016-01-15 17:56:32 -08:00
2016-01-14 16:00:49 -08:00
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…