X-Git-Url: https://git.stricted.de/?a=blobdiff_plain;f=kernel%2Fprintk.c;h=e20087156cdb23172a5b4de466544f5b8901c48d;hb=bdc132d780ce288900a0fc0cd8c39e2273bc2be9;hp=617bc0d08e2b77ae53b7b6ea28700f3298b9b891;hpb=97a3fbdc306f871da3be556c9d623a22363bd2a6;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git diff --git a/kernel/printk.c b/kernel/printk.c index 617bc0d08e2b..e20087156cdb 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -1331,7 +1331,7 @@ static void call_console_drivers(int level, const char *text, size_t len) { struct console *con; - trace_console(text, len); + trace_console_rcuidle(text, len); if (level >= console_loglevel && !ignore_loglevel) return; @@ -2131,7 +2131,7 @@ void console_unlock(void) static u64 seen_seq; unsigned long flags; bool wake_klogd = false; - bool retry; + bool do_cond_resched, retry; #ifdef LOG_TOO_MUCH_WARNING unsigned long total_log_size = 0; unsigned long long t1 = 0, t2 = 0; @@ -2139,11 +2139,23 @@ void console_unlock(void) int org_loglevel = console_loglevel; #endif + 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 */ @@ -2239,6 +2251,9 @@ skip: call_console_drivers(level, text, len); #endif local_irq_restore(flags); + + if (do_cond_resched) + cond_resched(); } console_locked = 0; mutex_release(&console_lock_dep_map, 1, _RET_IP_); @@ -2307,6 +2322,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 */