|
@@ -2234,13 +2234,24 @@ void console_unlock(void)
|
|
|
static u64 seen_seq;
|
|
|
unsigned long flags;
|
|
|
bool wake_klogd = false;
|
|
|
- bool retry;
|
|
|
+ bool do_cond_resched, retry;
|
|
|
|
|
|
if (console_suspended) {
|
|
|
up_console_sem();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * Console drivers are called under logbuf_lock, so
|
|
|
+ * @console_may_schedule should be cleared before; however, we may
|
|
|
+ * end up dumping a lot of lines, for example, if called from
|
|
|
+ * console registration path, and should invoke cond_resched()
|
|
|
+ * between lines if allowable. Not doing so can cause a very long
|
|
|
+ * scheduling stall on a slow console leading to RCU stall and
|
|
|
+ * softlockup warnings which exacerbate the issue with more
|
|
|
+ * messages practically incapacitating the system.
|
|
|
+ */
|
|
|
+ do_cond_resched = console_may_schedule;
|
|
|
console_may_schedule = 0;
|
|
|
|
|
|
/* flush buffered message fragment immediately to console */
|
|
@@ -2312,6 +2323,9 @@ skip:
|
|
|
call_console_drivers(level, ext_text, ext_len, text, len);
|
|
|
start_critical_timings();
|
|
|
local_irq_restore(flags);
|
|
|
+
|
|
|
+ if (do_cond_resched)
|
|
|
+ cond_resched();
|
|
|
}
|
|
|
console_locked = 0;
|
|
|
|
|
@@ -2379,6 +2393,25 @@ void console_unblank(void)
|
|
|
console_unlock();
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * console_flush_on_panic - flush console content on panic
|
|
|
+ *
|
|
|
+ * Immediately output all pending messages no matter what.
|
|
|
+ */
|
|
|
+void console_flush_on_panic(void)
|
|
|
+{
|
|
|
+ /*
|
|
|
+ * If someone else is holding the console lock, trylock will fail
|
|
|
+ * and may_schedule may be set. Ignore and proceed to unlock so
|
|
|
+ * that messages are flushed out. As this can be called from any
|
|
|
+ * context and we don't want to get preempted while flushing,
|
|
|
+ * ensure may_schedule is cleared.
|
|
|
+ */
|
|
|
+ console_trylock();
|
|
|
+ console_may_schedule = 0;
|
|
|
+ console_unlock();
|
|
|
+}
|
|
|
+
|
|
|
/*
|
|
|
* Return the console tty driver structure and its associated index
|
|
|
*/
|