aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2012-09-19 14:50:37 +0200
committerSebastian Andrzej Siewior <bigeasy@linutronix.de>2016-02-13 00:36:24 +0100
commit8b243b07a24ba4fbfa77d301efc5fad6f0dae3fa (patch)
treef745bf369e8b21daa102e5d692b78c0883e92f77
parenta6d7965037905e3ddf1b43be0bb29de8b87b132a (diff)
downloadrt-linux-8b243b07a24ba4fbfa77d301efc5fad6f0dae3fa.tar.gz
printk: Make rt aware
Drop the lock before calling the console driver and do not disable interrupts while printing to a serial console. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--kernel/printk/printk.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index e0961954c00243..763af49002fc08 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1502,6 +1502,7 @@ static void call_console_drivers(int level,
if (!console_drivers)
return;
+ migrate_disable();
for_each_console(con) {
if (exclusive_console && con != exclusive_console)
continue;
@@ -1517,6 +1518,7 @@ static void call_console_drivers(int level,
else
con->write(con, text, len);
}
+ migrate_enable();
}
/*
@@ -1577,6 +1579,15 @@ static inline int can_use_console(unsigned int cpu)
static int console_trylock_for_printk(void)
{
unsigned int cpu = smp_processor_id();
+#ifdef CONFIG_PREEMPT_RT_FULL
+ int lock = !early_boot_irqs_disabled && (preempt_count() == 0) &&
+ !irqs_disabled();
+#else
+ int lock = 1;
+#endif
+
+ if (!lock)
+ return 0;
if (!console_trylock())
return 0;
@@ -1879,8 +1890,7 @@ asmlinkage int vprintk_emit(int facility, int level,
* console_sem which would prevent anyone from printing to
* console
*/
- preempt_disable();
-
+ migrate_disable();
/*
* Try to acquire and then immediately release the console
* semaphore. The release will print out buffers and wake up
@@ -1888,7 +1898,7 @@ asmlinkage int vprintk_emit(int facility, int level,
*/
if (console_trylock_for_printk())
console_unlock();
- preempt_enable();
+ migrate_enable();
lockdep_on();
}
@@ -2248,11 +2258,16 @@ static void console_cont_flush(char *text, size_t size)
goto out;
len = cont_print_text(text, size);
+#ifdef CONFIG_PREEMPT_RT_FULL
+ raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+ call_console_drivers(cont.level, NULL, 0, text, len);
+#else
raw_spin_unlock(&logbuf_lock);
stop_critical_timings();
call_console_drivers(cont.level, NULL, 0, text, len);
start_critical_timings();
local_irq_restore(flags);
+#endif
return;
out:
raw_spin_unlock_irqrestore(&logbuf_lock, flags);
@@ -2351,12 +2366,17 @@ skip:
console_idx = log_next(console_idx);
console_seq++;
console_prev = msg->flags;
+#ifdef CONFIG_PREEMPT_RT_FULL
+ raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+ call_console_drivers(level, ext_text, ext_len, text, len);
+#else
raw_spin_unlock(&logbuf_lock);
stop_critical_timings(); /* don't trace print latency */
call_console_drivers(level, ext_text, ext_len, text, len);
start_critical_timings();
local_irq_restore(flags);
+#endif
}
console_locked = 0;