diff options
Diffstat (limited to 'kernel/printk.c')
-rw-r--r-- | kernel/printk.c | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/kernel/printk.c b/kernel/printk.c index 13c0a1143f49..b663c2c95d39 100644 --- a/kernel/printk.c +++ b/kernel/printk.c | |||
@@ -44,6 +44,9 @@ | |||
44 | 44 | ||
45 | #include <asm/uaccess.h> | 45 | #include <asm/uaccess.h> |
46 | 46 | ||
47 | #define CREATE_TRACE_POINTS | ||
48 | #include <trace/events/printk.h> | ||
49 | |||
47 | /* | 50 | /* |
48 | * Architectures can override it: | 51 | * Architectures can override it: |
49 | */ | 52 | */ |
@@ -542,6 +545,8 @@ MODULE_PARM_DESC(ignore_loglevel, "ignore loglevel setting, to" | |||
542 | static void _call_console_drivers(unsigned start, | 545 | static void _call_console_drivers(unsigned start, |
543 | unsigned end, int msg_log_level) | 546 | unsigned end, int msg_log_level) |
544 | { | 547 | { |
548 | trace_console(&LOG_BUF(0), start, end, log_buf_len); | ||
549 | |||
545 | if ((msg_log_level < console_loglevel || ignore_loglevel) && | 550 | if ((msg_log_level < console_loglevel || ignore_loglevel) && |
546 | console_drivers && start != end) { | 551 | console_drivers && start != end) { |
547 | if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) { | 552 | if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) { |
@@ -702,6 +707,9 @@ static bool printk_time = 0; | |||
702 | #endif | 707 | #endif |
703 | module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR); | 708 | module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR); |
704 | 709 | ||
710 | static bool always_kmsg_dump; | ||
711 | module_param_named(always_kmsg_dump, always_kmsg_dump, bool, S_IRUGO | S_IWUSR); | ||
712 | |||
705 | /* Check if we have any console registered that can be called early in boot. */ | 713 | /* Check if we have any console registered that can be called early in boot. */ |
706 | static int have_callable_console(void) | 714 | static int have_callable_console(void) |
707 | { | 715 | { |
@@ -1208,13 +1216,27 @@ int is_console_locked(void) | |||
1208 | return console_locked; | 1216 | return console_locked; |
1209 | } | 1217 | } |
1210 | 1218 | ||
1219 | /* | ||
1220 | * Delayed printk facility, for scheduler-internal messages: | ||
1221 | */ | ||
1222 | #define PRINTK_BUF_SIZE 512 | ||
1223 | |||
1224 | #define PRINTK_PENDING_WAKEUP 0x01 | ||
1225 | #define PRINTK_PENDING_SCHED 0x02 | ||
1226 | |||
1211 | static DEFINE_PER_CPU(int, printk_pending); | 1227 | static DEFINE_PER_CPU(int, printk_pending); |
1228 | static DEFINE_PER_CPU(char [PRINTK_BUF_SIZE], printk_sched_buf); | ||
1212 | 1229 | ||
1213 | void printk_tick(void) | 1230 | void printk_tick(void) |
1214 | { | 1231 | { |
1215 | if (__this_cpu_read(printk_pending)) { | 1232 | if (__this_cpu_read(printk_pending)) { |
1216 | __this_cpu_write(printk_pending, 0); | 1233 | int pending = __this_cpu_xchg(printk_pending, 0); |
1217 | wake_up_interruptible(&log_wait); | 1234 | if (pending & PRINTK_PENDING_SCHED) { |
1235 | char *buf = __get_cpu_var(printk_sched_buf); | ||
1236 | printk(KERN_WARNING "[sched_delayed] %s", buf); | ||
1237 | } | ||
1238 | if (pending & PRINTK_PENDING_WAKEUP) | ||
1239 | wake_up_interruptible(&log_wait); | ||
1218 | } | 1240 | } |
1219 | } | 1241 | } |
1220 | 1242 | ||
@@ -1228,7 +1250,7 @@ int printk_needs_cpu(int cpu) | |||
1228 | void wake_up_klogd(void) | 1250 | void wake_up_klogd(void) |
1229 | { | 1251 | { |
1230 | if (waitqueue_active(&log_wait)) | 1252 | if (waitqueue_active(&log_wait)) |
1231 | this_cpu_write(printk_pending, 1); | 1253 | this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP); |
1232 | } | 1254 | } |
1233 | 1255 | ||
1234 | /** | 1256 | /** |
@@ -1621,6 +1643,26 @@ late_initcall(printk_late_init); | |||
1621 | 1643 | ||
1622 | #if defined CONFIG_PRINTK | 1644 | #if defined CONFIG_PRINTK |
1623 | 1645 | ||
1646 | int printk_sched(const char *fmt, ...) | ||
1647 | { | ||
1648 | unsigned long flags; | ||
1649 | va_list args; | ||
1650 | char *buf; | ||
1651 | int r; | ||
1652 | |||
1653 | local_irq_save(flags); | ||
1654 | buf = __get_cpu_var(printk_sched_buf); | ||
1655 | |||
1656 | va_start(args, fmt); | ||
1657 | r = vsnprintf(buf, PRINTK_BUF_SIZE, fmt, args); | ||
1658 | va_end(args); | ||
1659 | |||
1660 | __this_cpu_or(printk_pending, PRINTK_PENDING_SCHED); | ||
1661 | local_irq_restore(flags); | ||
1662 | |||
1663 | return r; | ||
1664 | } | ||
1665 | |||
1624 | /* | 1666 | /* |
1625 | * printk rate limiting, lifted from the networking subsystem. | 1667 | * printk rate limiting, lifted from the networking subsystem. |
1626 | * | 1668 | * |
@@ -1732,6 +1774,9 @@ void kmsg_dump(enum kmsg_dump_reason reason) | |||
1732 | unsigned long l1, l2; | 1774 | unsigned long l1, l2; |
1733 | unsigned long flags; | 1775 | unsigned long flags; |
1734 | 1776 | ||
1777 | if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump) | ||
1778 | return; | ||
1779 | |||
1735 | /* Theoretically, the log could move on after we do this, but | 1780 | /* Theoretically, the log could move on after we do this, but |
1736 | there's not a lot we can do about that. The new messages | 1781 | there's not a lot we can do about that. The new messages |
1737 | will overwrite the start of what we dump. */ | 1782 | will overwrite the start of what we dump. */ |