Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

panic/printk: replace this_cpu_in_panic() with panic_on_this_cpu()

The helper this_cpu_in_panic() duplicated logic already provided by
panic_on_this_cpu().

Remove this_cpu_in_panic() and switch all users to panic_on_this_cpu().

This simplifies the code and avoids having two helpers for the same check.

Link: https://lkml.kernel.org/r/20250825022947.1596226-8-wangjinchao600@gmail.com
Signed-off-by: Jinchao Wang <wangjinchao600@gmail.com>
Cc: Anna Schumaker <anna.schumaker@oracle.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: "Darrick J. Wong" <djwong@kernel.org>
Cc: Dave Young <dyoung@redhat.com>
Cc: Doug Anderson <dianders@chromium.org>
Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Joanthan Cameron <Jonathan.Cameron@huawei.com>
Cc: Joel Granados <joel.granados@kernel.org>
Cc: John Ogness <john.ogness@linutronix.de>
Cc: Kees Cook <kees@kernel.org>
Cc: Li Huafei <lihuafei1@huawei.com>
Cc: "Luck, Tony" <tony.luck@intel.com>
Cc: Luo Gengkun <luogengkun@huaweicloud.com>
Cc: Max Kellermann <max.kellermann@ionos.com>
Cc: Nam Cao <namcao@linutronix.de>
Cc: oushixiong <oushixiong@kylinos.cn>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Qianqiang Liu <qianqiang.liu@163.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Sohil Mehta <sohil.mehta@intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleinxer <tglx@linutronix.de>
Cc: Thomas Zimemrmann <tzimmermann@suse.de>
Cc: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Yicong Yang <yangyicong@hisilicon.com>
Cc: Yunhui Cui <cuiyunhui@bytedance.com>
Cc: Yury Norov (NVIDIA) <yury.norov@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Jinchao Wang and committed by
Andrew Morton
c6be36e2 2325e8ea

+6 -19
-2
include/linux/printk.h
··· 330 330 331 331 #endif 332 332 333 - bool this_cpu_in_panic(void); 334 - 335 333 #ifdef CONFIG_SMP 336 334 extern int __printk_cpu_sync_try_get(void); 337 335 extern void __printk_cpu_sync_wait(void);
+1 -1
kernel/panic.c
··· 348 348 */ 349 349 bool panic_on_other_cpu(void) 350 350 { 351 - return (panic_in_progress() && !this_cpu_in_panic()); 351 + return (panic_in_progress() && !panic_on_this_cpu()); 352 352 } 353 353 EXPORT_SYMBOL(panic_on_other_cpu); 354 354
+1 -1
kernel/printk/nbcon.c
··· 1394 1394 { 1395 1395 unsigned int *cpu_emergency_nesting; 1396 1396 1397 - if (this_cpu_in_panic()) 1397 + if (panic_on_this_cpu()) 1398 1398 return NBCON_PRIO_PANIC; 1399 1399 1400 1400 cpu_emergency_nesting = nbcon_get_cpu_emergency_nesting();
+2 -13
kernel/printk/printk.c
··· 17 17 * 01Mar01 Andrew Morton 18 18 */ 19 19 20 + #include "linux/panic.h" 20 21 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 21 22 22 23 #include <linux/kernel.h> ··· 346 345 } 347 346 #define up_console_sem() __up_console_sem(_RET_IP_) 348 347 349 - /* Return true if a panic is in progress on the current CPU. */ 350 - bool this_cpu_in_panic(void) 351 - { 352 - /* 353 - * We can use raw_smp_processor_id() here because it is impossible for 354 - * the task to be migrated to the panic_cpu, or away from it. If 355 - * panic_cpu has already been set, and we're not currently executing on 356 - * that CPU, then we never will be. 357 - */ 358 - return unlikely(atomic_read(&panic_cpu) == raw_smp_processor_id()); 359 - } 360 - 361 348 /* 362 349 * Return true if a panic is in progress on a remote CPU. 363 350 * ··· 354 365 */ 355 366 bool other_cpu_in_panic(void) 356 367 { 357 - return (panic_in_progress() && !this_cpu_in_panic()); 368 + return (panic_in_progress() && !panic_on_this_cpu()); 358 369 } 359 370 360 371 /*
+1 -1
kernel/printk/printk_ringbuffer.c
··· 2143 2143 * But it would have the sequence number returned 2144 2144 * by "prb_next_reserve_seq() - 1". 2145 2145 */ 2146 - if (this_cpu_in_panic() && 2146 + if (panic_on_this_cpu() && 2147 2147 (!debug_non_panic_cpus || legacy_allow_panic_sync) && 2148 2148 ((*seq + 1) < prb_next_reserve_seq(rb))) { 2149 2149 (*seq)++;
+1 -1
lib/dump_stack.c
··· 102 102 */ 103 103 asmlinkage __visible void dump_stack_lvl(const char *log_lvl) 104 104 { 105 - bool in_panic = this_cpu_in_panic(); 105 + bool in_panic = panic_on_this_cpu(); 106 106 unsigned long flags; 107 107 108 108 /*