[printk,v2,1/4] printk: For @suppress_panic_printk check other panic

Message ID 20231013204340.1112036-2-john.ogness@linutronix.de
State New
Headers
Series fix console flushing on panic |

Commit Message

John Ogness Oct. 13, 2023, 8:43 p.m. UTC
  Currently @suppress_panic_printk is checked along with
non-matching @panic_cpu and current CPU. This works
because @suppress_panic_printk is only set when
panic_in_progress() is true.

Rather than relying on the @suppress_panic_printk semantics,
use the concise helper function other_cpu_in_progress(). The
helper function exists to avoid open coding such tests.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
 kernel/printk/printk.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Petr Mladek Oct. 16, 2023, 1:05 p.m. UTC | #1
On Fri 2023-10-13 22:49:37, John Ogness wrote:
> Currently @suppress_panic_printk is checked along with
> non-matching @panic_cpu and current CPU. This works
> because @suppress_panic_printk is only set when
> panic_in_progress() is true.
> 
> Rather than relying on the @suppress_panic_printk semantics,
> use the concise helper function other_cpu_in_progress(). The
> helper function exists to avoid open coding such tests.
> 
> Signed-off-by: John Ogness <john.ogness@linutronix.de>

Reviewed-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr
  

Patch

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 80eb79177bab..abb6a50ee26f 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2272,8 +2272,7 @@  asmlinkage int vprintk_emit(int facility, int level,
 	if (unlikely(suppress_printk))
 		return 0;
 
-	if (unlikely(suppress_panic_printk) &&
-	    atomic_read(&panic_cpu) != raw_smp_processor_id())
+	if (unlikely(suppress_panic_printk) && other_cpu_in_panic())
 		return 0;
 
 	if (level == LOGLEVEL_SCHED) {