[PATCH] printk: Do not disable preemption when calling consoles in RT

From: Steven Rostedt (VMware)
Date: Fri Dec 14 2018 - 21:36:55 EST


console_unlock() may call consoles that call spin_lock(), where spin_lock is
a mutex in PREEMPT_RT. Although mainline may be worried about preempted
holders of the console lock from preventing printk() output, the RT kernel
does not.

Use migrate_disable() to disable preemption when !RT, but we really don't
care if the task stays on the CPU or not for RT. It just has to be able to
schedule.

Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
kernel/printk/printk.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 8a7c4f79fca0..029ae3caa80e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1811,7 +1811,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
@@ -1819,7 +1819,7 @@ asmlinkage int vprintk_emit(int facility, int level,
*/
if (may_trylock && console_trylock())
console_unlock();
- preempt_enable();
+ migrate_enable();
}

return printed_len;
--
2.19.2