aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2017-10-11 12:46:47 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2017-10-13 11:08:01 -0400
commitaf41acf8347dd6d11a2a29a11e2866ca4892d600 (patch)
tree86c62ba857c8a0de3fafc4928fca9b01b0f232de
parent8715b108cd75523c9b2e833cdcd7aeb363767f95 (diff)
printk: Remove superfluous memory barriers from printk_safe
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. Link: http://lkml.kernel.org/r/20171011124647.7781f98f@gandalf.local.home Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--kernel/printk/printk_safe.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c
index 3cdaeaef9ce1..724d9292d4b9 100644
--- a/kernel/printk/printk_safe.c
+++ b/kernel/printk/printk_safe.c
@@ -39,7 +39,7 @@
39 * There are situations when we want to make sure that all buffers 39 * There are situations when we want to make sure that all buffers
40 * were handled or when IRQs are blocked. 40 * were handled or when IRQs are blocked.
41 */ 41 */
42static int printk_safe_irq_ready; 42static int printk_safe_irq_ready __read_mostly;
43 43
44#define SAFE_LOG_BUF_LEN ((1 << CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT) - \ 44#define SAFE_LOG_BUF_LEN ((1 << CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT) - \
45 sizeof(atomic_t) - \ 45 sizeof(atomic_t) - \
@@ -63,11 +63,8 @@ static DEFINE_PER_CPU(struct printk_safe_seq_buf, nmi_print_seq);
63/* Get flushed in a more safe context. */ 63/* Get flushed in a more safe context. */
64static void queue_flush_work(struct printk_safe_seq_buf *s) 64static void queue_flush_work(struct printk_safe_seq_buf *s)
65{ 65{
66 if (printk_safe_irq_ready) { 66 if (printk_safe_irq_ready)
67 /* Make sure that IRQ work is really initialized. */
68 smp_rmb();
69 irq_work_queue(&s->work); 67 irq_work_queue(&s->work);
70 }
71} 68}
72 69
73/* 70/*
@@ -398,8 +395,12 @@ void __init printk_safe_init(void)
398#endif 395#endif
399 } 396 }
400 397
401 /* Make sure that IRQ works are initialized before enabling. */ 398 /*
402 smp_wmb(); 399 * In the highly unlikely event that a NMI were to trigger at
400 * this moment. Make sure IRQ work is set up before this
401 * variable is set.
402 */
403 barrier();
403 printk_safe_irq_ready = 1; 404 printk_safe_irq_ready = 1;
404 405
405 /* Flush pending messages that did not have scheduled IRQ works. */ 406 /* Flush pending messages that did not have scheduled IRQ works. */