Thread (4 messages) 4 messages, 2 authors, 2018-07-27

[PREEMPT_RT]: Using printk-rt-aware.patch in non-rt kernel

From: Sebastian Andrzej Siewior <hidden>
Date: 2018-07-27 09:05:37
Also in: linux-rt-users, lkml
Subsystem: printk, the rest · Maintainers: Petr Mladek, Linus Torvalds

On 2018-07-26 23:38:05 [+0530], Pintu Kumar wrote:
quoted
quoted
Is there a way we can fix this issue on non-rt kernel?
I would guess that a wakeup to klogd would fix it.
Sorry, can you elaborate more about "wakeup to klogd".
I wanted to try it and check.
Something like this should do the work.
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 179ad787a08c..411f9ed5f051 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1927,6 +1927,8 @@ static size_t log_output(int facility, int level, enum log_flags lflags, const c
 	return log_store(facility, level, lflags, 0, dict, dictlen, text, text_len);
 }
 
+static void printk_flush_pending_output(void);
+
 asmlinkage int vprintk_emit(int facility, int level,
 			    const char *dict, size_t dictlen,
 			    const char *fmt, va_list args)
@@ -2026,6 +2028,9 @@ asmlinkage int vprintk_emit(int facility, int level,
 		 */
 		if (may_trylock && console_trylock_spinning())
 			console_unlock();
+		else if (!may_trylock)
+			printk_flush_pending_output();
+
 		migrate_enable();
 	}
 
@@ -2987,6 +2992,13 @@ static DEFINE_PER_CPU(struct irq_work, wake_up_klogd_work) = {
 	.flags = IRQ_WORK_LAZY,
 };
 
+static void printk_flush_pending_output(void)
+{
+	/* preemption or interrupts need to be disabled */
+	__this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT);
+	irq_work_queue(this_cpu_ptr(&wake_up_klogd_work));
+}
+
 void wake_up_klogd(void)
 {
 	preempt_disable();
Sebastian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help