public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] printk: Remove superfluous memory barriers from printk_safe
@ 2017-10-11 16:46 Steven Rostedt
  2017-10-12  9:34 ` Petr Mladek
  2017-10-14  9:21 ` Sergey Senozhatsky
  0 siblings, 2 replies; 7+ messages in thread
From: Steven Rostedt @ 2017-10-11 16:46 UTC (permalink / raw)
  To: LKML; +Cc: Petr Mladek, Peter Zijlstra, Andrew Morton, Sergey Senozhatsky

From: Steven Rostedt (VMware) <rostedt@goodmis.org>

The variable printk_safe_irq_ready is set and never cleared at system
boot up, when there's only one CPU active. It is set before other
CPUs come on line. Also, it is extremely unlikely that an NMI would
trigger this early in boot up (which I wonder why we even have this
variable at all).

Also mark the printk_safe_irq_ready as read mostly, as it is set at
system boot up, and never touched again.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index 3cdaeae..724d929 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -39,7 +39,7 @@
  * There are situations when we want to make sure that all buffers
  * were handled or when IRQs are blocked.
  */
-static int printk_safe_irq_ready;
+static int printk_safe_irq_ready __read_mostly;
 
 #define SAFE_LOG_BUF_LEN ((1 << CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT) -	\
 				sizeof(atomic_t) -			\
@@ -63,11 +63,8 @@ static DEFINE_PER_CPU(struct printk_safe_seq_buf, nmi_print_seq);
 /* Get flushed in a more safe context. */
 static void queue_flush_work(struct printk_safe_seq_buf *s)
 {
-	if (printk_safe_irq_ready) {
-		/* Make sure that IRQ work is really initialized. */
-		smp_rmb();
+	if (printk_safe_irq_ready)
 		irq_work_queue(&s->work);
-	}
 }
 
 /*
@@ -398,8 +395,12 @@ void __init printk_safe_init(void)
 #endif
 	}
 
-	/* Make sure that IRQ works are initialized before enabling. */
-	smp_wmb();
+	/*
+	 * In the highly unlikely event that a NMI were to trigger at
+	 * this moment. Make sure IRQ work is set up before this
+	 * variable is set.
+	 */
+	barrier();
 	printk_safe_irq_ready = 1;
 
 	/* Flush pending messages that did not have scheduled IRQ works. */

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-10-16 11:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-11 16:46 [PATCH] printk: Remove superfluous memory barriers from printk_safe Steven Rostedt
2017-10-12  9:34 ` Petr Mladek
2017-10-14  9:21 ` Sergey Senozhatsky
2017-10-16  0:27   ` Steven Rostedt
2017-10-16  8:12     ` Petr Mladek
2017-10-16 11:08       ` Sergey Senozhatsky
2017-10-16 11:05     ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox