linux/debian/patches/features/all/rt/printk-rt-aware.patch

102 lines
2.8 KiB
Diff

Subject: printk: Make rt aware
From: Thomas Gleixner <tglx@linutronix.de>
Date: Wed, 19 Sep 2012 14:50:37 +0200
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.4/patches-4.4-rt3.tar.xz
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>
---
kernel/printk/printk.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1443,6 +1443,7 @@ static void call_console_drivers(int lev
if (!console_drivers)
return;
+ migrate_disable();
for_each_console(con) {
if (exclusive_console && con != exclusive_console)
continue;
@@ -1458,6 +1459,7 @@ static void call_console_drivers(int lev
else
con->write(con, text, len);
}
+ migrate_enable();
}
/*
@@ -1518,6 +1520,15 @@ static inline int can_use_console(unsign
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;
@@ -1876,8 +1887,7 @@ asmlinkage int vprintk_emit(int facility
* 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
@@ -1885,7 +1895,7 @@ asmlinkage int vprintk_emit(int facility
*/
if (console_trylock_for_printk())
console_unlock();
- preempt_enable();
+ migrate_enable();
lockdep_on();
}
@@ -2245,11 +2255,16 @@ static void console_cont_flush(char *tex
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);
@@ -2348,12 +2363,17 @@ void console_unlock(void)
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;