workqueue: implicit ordered attribute should be overridable
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / kernel / printk.c
index 8212c1aef125f2d4290cbe0e55564d7e9a5a57de..8acc98aafa6ea189fac01726d3e819703ce743e6 100644 (file)
@@ -107,7 +107,7 @@ static struct console *exclusive_console;
  */
 struct console_cmdline
 {
-       char    name[8];                        /* Name of the driver       */
+       char    name[16];                       /* Name of the driver       */
        int     index;                          /* Minor dev. to use        */
        char    *options;                       /* Options for the driver   */
 #ifdef CONFIG_A11Y_BRAILLE_CONSOLE
@@ -1270,7 +1270,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;
@@ -1369,9 +1369,9 @@ static int console_trylock_for_printk(unsigned int cpu)
                }
        }
        logbuf_cpu = UINT_MAX;
+       raw_spin_unlock(&logbuf_lock);
        if (wake)
                up(&console_sem);
-       raw_spin_unlock(&logbuf_lock);
        return retval;
 }
 
@@ -2033,13 +2033,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 */
@@ -2096,6 +2107,9 @@ skip:
                call_console_drivers(level, text, len);
                start_critical_timings();
                local_irq_restore(flags);
+
+               if (do_cond_resched)
+                       cond_resched();
        }
        console_locked = 0;
        mutex_release(&console_lock_dep_map, 1, _RET_IP_);
@@ -2164,6 +2178,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
  */
@@ -2290,6 +2323,8 @@ void register_console(struct console *newcon)
         */
        for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0];
                        i++) {
+               BUILD_BUG_ON(sizeof(console_cmdline[i].name) !=
+                            sizeof(newcon->name));
                if (strcmp(console_cmdline[i].name, newcon->name) != 0)
                        continue;
                if (newcon->index >= 0 &&
@@ -2485,7 +2520,7 @@ void wake_up_klogd(void)
        preempt_enable();
 }
 
-int printk_sched(const char *fmt, ...)
+int printk_deferred(const char *fmt, ...)
 {
        unsigned long flags;
        va_list args;