Merge tag 'trace-seq-buf-3.19-v2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 13 Dec 2014 22:04:41 +0000 (14:04 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 13 Dec 2014 22:04:41 +0000 (14:04 -0800)
Pull tracing fixlet from Steven Rostedt:
 "Remove unnecessary preempt_disable in printk()"

* tag 'trace-seq-buf-3.19-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
  printk: Do not disable preemption for accessing printk_func

1  2 
kernel/printk/printk.c

diff --combined kernel/printk/printk.c
@@@ -62,6 -62,9 +62,6 @@@ int console_printk[4] = 
        CONSOLE_LOGLEVEL_DEFAULT,       /* default_console_loglevel */
  };
  
 -/* Deferred messaged from sched code are marked by this special level */
 -#define SCHED_MESSAGE_LOGLEVEL -2
 -
  /*
   * Low level drivers may need that to know if they can schedule in
   * their unblank() callback or not. So let's export it.
@@@ -477,7 -480,7 +477,7 @@@ static int syslog_action_restricted(in
               type != SYSLOG_ACTION_SIZE_BUFFER;
  }
  
 -static int check_syslog_permissions(int type, bool from_file)
 +int check_syslog_permissions(int type, bool from_file)
  {
        /*
         * If this is from /proc/kmsg and we've already opened it, then we've
@@@ -1256,7 -1259,7 +1256,7 @@@ static int syslog_print_all(char __use
  int do_syslog(int type, char __user *buf, int len, bool from_file)
  {
        bool clear = false;
 -      static int saved_console_loglevel = -1;
 +      static int saved_console_loglevel = LOGLEVEL_DEFAULT;
        int error;
  
        error = check_syslog_permissions(type, from_file);
                break;
        /* Disable logging to console */
        case SYSLOG_ACTION_CONSOLE_OFF:
 -              if (saved_console_loglevel == -1)
 +              if (saved_console_loglevel == LOGLEVEL_DEFAULT)
                        saved_console_loglevel = console_loglevel;
                console_loglevel = minimum_console_loglevel;
                break;
        /* Enable logging to console */
        case SYSLOG_ACTION_CONSOLE_ON:
 -              if (saved_console_loglevel != -1) {
 +              if (saved_console_loglevel != LOGLEVEL_DEFAULT) {
                        console_loglevel = saved_console_loglevel;
 -                      saved_console_loglevel = -1;
 +                      saved_console_loglevel = LOGLEVEL_DEFAULT;
                }
                break;
        /* Set level of messages printed to console */
                        len = minimum_console_loglevel;
                console_loglevel = len;
                /* Implicitly re-enable logging to console */
 -              saved_console_loglevel = -1;
 +              saved_console_loglevel = LOGLEVEL_DEFAULT;
                error = 0;
                break;
        /* Number of chars in the log buffer */
@@@ -1624,10 -1627,10 +1624,10 @@@ asmlinkage int vprintk_emit(int facilit
        int printed_len = 0;
        bool in_sched = false;
        /* cpu currently holding logbuf_lock in this function */
 -      static volatile unsigned int logbuf_cpu = UINT_MAX;
 +      static unsigned int logbuf_cpu = UINT_MAX;
  
 -      if (level == SCHED_MESSAGE_LOGLEVEL) {
 -              level = -1;
 +      if (level == LOGLEVEL_SCHED) {
 +              level = LOGLEVEL_DEFAULT;
                in_sched = true;
        }
  
                        const char *end_of_header = printk_skip_level(text);
                        switch (kern_level) {
                        case '0' ... '7':
 -                              if (level == -1)
 +                              if (level == LOGLEVEL_DEFAULT)
                                        level = kern_level - '0';
 +                              /* fallthrough */
                        case 'd':       /* KERN_DEFAULT */
                                lflags |= LOG_PREFIX;
                        }
                }
        }
  
 -      if (level == -1)
 +      if (level == LOGLEVEL_DEFAULT)
                level = default_message_loglevel;
  
        if (dict)
@@@ -1786,7 -1788,7 +1786,7 @@@ EXPORT_SYMBOL(vprintk_emit)
  
  asmlinkage int vprintk(const char *fmt, va_list args)
  {
 -      return vprintk_emit(0, -1, NULL, 0, fmt, args);
 +      return vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
  }
  EXPORT_SYMBOL(vprintk);
  
@@@ -1815,7 -1817,7 +1815,7 @@@ int vprintk_default(const char *fmt, va
                return r;
        }
  #endif
 -      r = vprintk_emit(0, -1, NULL, 0, fmt, args);
 +      r = vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, 0, fmt, args);
  
        return r;
  }
@@@ -1857,10 -1859,16 +1857,16 @@@ asmlinkage __visible int printk(const c
        int r;
  
        va_start(args, fmt);
-       preempt_disable();
+       /*
+        * If a caller overrides the per_cpu printk_func, then it needs
+        * to disable preemption when calling printk(). Otherwise
+        * the printk_func should be set to the default. No need to
+        * disable preemption here.
+        */
        vprintk_func = this_cpu_read(printk_func);
        r = vprintk_func(fmt, args);
-       preempt_enable();
        va_end(args);
  
        return r;
@@@ -1902,20 -1910,23 +1908,20 @@@ DEFINE_PER_CPU(printk_func_t, printk_fu
  #ifdef CONFIG_EARLY_PRINTK
  struct console *early_console;
  
 -void early_vprintk(const char *fmt, va_list ap)
 -{
 -      if (early_console) {
 -              char buf[512];
 -              int n = vscnprintf(buf, sizeof(buf), fmt, ap);
 -
 -              early_console->write(early_console, buf, n);
 -      }
 -}
 -
  asmlinkage __visible void early_printk(const char *fmt, ...)
  {
        va_list ap;
 +      char buf[512];
 +      int n;
 +
 +      if (!early_console)
 +              return;
  
        va_start(ap, fmt);
 -      early_vprintk(fmt, ap);
 +      n = vscnprintf(buf, sizeof(buf), fmt, ap);
        va_end(ap);
 +
 +      early_console->write(early_console, buf, n);
  }
  #endif
  
@@@ -2652,7 -2663,7 +2658,7 @@@ int printk_deferred(const char *fmt, ..
  
        preempt_disable();
        va_start(args, fmt);
 -      r = vprintk_emit(0, SCHED_MESSAGE_LOGLEVEL, NULL, 0, fmt, args);
 +      r = vprintk_emit(0, LOGLEVEL_SCHED, NULL, 0, fmt, args);
        va_end(args);
  
        __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);