0001
0002
0003
0004
0005
0006 #include <linux/preempt.h>
0007 #include <linux/kdb.h>
0008 #include <linux/smp.h>
0009 #include <linux/cpumask.h>
0010 #include <linux/printk.h>
0011 #include <linux/kprobes.h>
0012
0013 #include "internal.h"
0014
0015 static DEFINE_PER_CPU(int, printk_context);
0016
0017
0018 void __printk_safe_enter(void)
0019 {
0020 this_cpu_inc(printk_context);
0021 }
0022
0023
0024 void __printk_safe_exit(void)
0025 {
0026 this_cpu_dec(printk_context);
0027 }
0028
0029 asmlinkage int vprintk(const char *fmt, va_list args)
0030 {
0031 #ifdef CONFIG_KGDB_KDB
0032
0033 if (unlikely(kdb_trap_printk && kdb_printf_cpu < 0))
0034 return vkdb_printf(KDB_MSGSRC_PRINTK, fmt, args);
0035 #endif
0036
0037
0038
0039
0040
0041 if (this_cpu_read(printk_context) || in_nmi()) {
0042 int len;
0043
0044 len = vprintk_store(0, LOGLEVEL_DEFAULT, NULL, fmt, args);
0045 defer_console_output();
0046 return len;
0047 }
0048
0049
0050 return vprintk_default(fmt, args);
0051 }
0052 EXPORT_SYMBOL(vprintk);