summaryrefslogtreecommitdiff
path: root/kernel/printk/printk.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2012-09-19 12:50:37 (GMT)
committerScott Wood <scottwood@freescale.com>2014-05-14 18:38:41 (GMT)
commit4ccae68638780917daf37a0941bf3280d17ef8b4 (patch)
tree6ae3b77a15496fa4c9f29d6d5414cbd2bfc113ac /kernel/printk/printk.c
parent7a417ab5cd0dfd3b12677704dbf47536ba28fd27 (diff)
downloadlinux-fsl-qoriq-4ccae68638780917daf37a0941bf3280d17ef8b4.tar.xz
printk-rt-aware.patch
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'kernel/printk/printk.c')
-rw-r--r--kernel/printk/printk.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 957c1a2..4c68d20 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1271,6 +1271,7 @@ static void call_console_drivers(int level, const char *text, size_t len)
if (!console_drivers)
return;
+ migrate_disable();
for_each_console(con) {
if (exclusive_console && con != exclusive_console)
continue;
@@ -1283,6 +1284,7 @@ static void call_console_drivers(int level, const char *text, size_t len)
continue;
con->write(con, text, len);
}
+ migrate_enable();
}
/*
@@ -1342,12 +1344,18 @@ static inline int can_use_console(unsigned int cpu)
* interrupts disabled. It should return with 'lockbuf_lock'
* released but interrupts still disabled.
*/
-static int console_trylock_for_printk(unsigned int cpu)
+static int console_trylock_for_printk(unsigned int cpu, unsigned long flags)
__releases(&logbuf_lock)
{
int retval = 0, wake = 0;
+#ifdef CONFIG_PREEMPT_RT_FULL
+ int lock = !early_boot_irqs_disabled && !irqs_disabled_flags(flags) &&
+ (preempt_count() <= 1);
+#else
+ int lock = 1;
+#endif
- if (console_trylock()) {
+ if (lock && console_trylock()) {
retval = 1;
/*
@@ -1682,8 +1690,15 @@ asmlinkage int vprintk_emit(int facility, int level,
* The console_trylock_for_printk() function will release 'logbuf_lock'
* regardless of whether it actually gets the console semaphore or not.
*/
- if (console_trylock_for_printk(this_cpu))
+ if (console_trylock_for_printk(this_cpu, flags)) {
+#ifndef CONFIG_PREEMPT_RT_FULL
+ console_unlock();
+#else
+ raw_local_irq_restore(flags);
console_unlock();
+ raw_local_irq_save(flags);
+#endif
+ }
lockdep_on();
out_restore_irqs:
@@ -2025,11 +2040,16 @@ static void console_cont_flush(char *text, size_t size)
goto out;
len = cont_print_text(text, size);
+#ifndef CONFIG_PREEMPT_RT_FULL
raw_spin_unlock(&logbuf_lock);
stop_critical_timings();
call_console_drivers(cont.level, text, len);
start_critical_timings();
local_irq_restore(flags);
+#else
+ raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+ call_console_drivers(cont.level, text, len);
+#endif
return;
out:
raw_spin_unlock_irqrestore(&logbuf_lock, flags);
@@ -2112,12 +2132,17 @@ skip:
console_idx = log_next(console_idx);
console_seq++;
console_prev = msg->flags;
- raw_spin_unlock(&logbuf_lock);
+#ifndef CONFIG_PREEMPT_RT_FULL
+ raw_spin_unlock(&logbuf_lock);
stop_critical_timings(); /* don't trace print latency */
call_console_drivers(level, text, len);
start_critical_timings();
local_irq_restore(flags);
+#else
+ raw_spin_unlock_irqrestore(&logbuf_lock, flags);
+ call_console_drivers(level, text, len);
+#endif
}
console_locked = 0;
mutex_release(&console_lock_dep_map, 1, _RET_IP_);