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 other_cpu_in_panic() with panic_on_other_cpu()

The helper other_cpu_in_panic() duplicated logic already provided by
panic_on_other_cpu().

Remove other_cpu_in_panic() and update all users to call
panic_on_other_cpu() instead.

This removes redundant code and makes panic handling consistent.

Link: https://lkml.kernel.org/r/20250825022947.1596226-9-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
d4a36db5 c6be36e2

+8 -20
-1
kernel/printk/internal.h
··· 332 332 unsigned long dropped; 333 333 }; 334 334 335 - bool other_cpu_in_panic(void); 336 335 bool printk_get_next_message(struct printk_message *pmsg, u64 seq, 337 336 bool is_extended, bool may_supress); 338 337
+4 -4
kernel/printk/nbcon.c
··· 255 255 * opportunity to perform any necessary cleanup if they were 256 256 * interrupted by the panic CPU while printing. 257 257 */ 258 - if (other_cpu_in_panic() && 258 + if (panic_on_other_cpu() && 259 259 (!is_reacquire || cur->unsafe_takeover)) { 260 260 return -EPERM; 261 261 } ··· 310 310 * Event #2 implies the new context is PANIC. 311 311 * Event #3 occurs when panic() has flushed the console. 312 312 * Event #4 occurs when a non-panic CPU reacquires. 313 - * Event #5 is not possible due to the other_cpu_in_panic() check 313 + * Event #5 is not possible due to the panic_on_other_cpu() check 314 314 * in nbcon_context_try_acquire_handover(). 315 315 */ 316 316 ··· 349 349 struct nbcon_state new; 350 350 351 351 /* Note that the caller must still remove the request! */ 352 - if (other_cpu_in_panic()) 352 + if (panic_on_other_cpu()) 353 353 return -EPERM; 354 354 355 355 /* ··· 447 447 * nbcon_waiter_matches(). In particular, the assumption that 448 448 * lower priorities are ignored during panic. 449 449 */ 450 - if (other_cpu_in_panic()) 450 + if (panic_on_other_cpu()) 451 451 return -EPERM; 452 452 453 453 /* Handover is not possible on the same CPU. */
+4 -15
kernel/printk/printk.c
··· 347 347 #define up_console_sem() __up_console_sem(_RET_IP_) 348 348 349 349 /* 350 - * Return true if a panic is in progress on a remote CPU. 351 - * 352 - * On true, the local CPU should immediately release any printing resources 353 - * that may be needed by the panic CPU. 354 - */ 355 - bool other_cpu_in_panic(void) 356 - { 357 - return (panic_in_progress() && !panic_on_this_cpu()); 358 - } 359 - 360 - /* 361 350 * This is used for debugging the mess that is the VT code by 362 351 * keeping track if we have the console semaphore held. It's 363 352 * definitely not the perfect debug tool (we don't know if _WE_ ··· 2380 2391 * non-panic CPUs are generating any messages, they will be 2381 2392 * silently dropped. 2382 2393 */ 2383 - if (other_cpu_in_panic() && 2394 + if (panic_on_other_cpu() && 2384 2395 !debug_non_panic_cpus && 2385 2396 !panic_triggering_all_cpu_backtrace) 2386 2397 return 0; ··· 2816 2827 might_sleep(); 2817 2828 2818 2829 /* On panic, the console_lock must be left to the panic cpu. */ 2819 - while (other_cpu_in_panic()) 2830 + while (panic_on_other_cpu()) 2820 2831 msleep(1000); 2821 2832 2822 2833 down_console_sem(); ··· 2836 2847 int console_trylock(void) 2837 2848 { 2838 2849 /* On panic, the console_lock must be left to the panic cpu. */ 2839 - if (other_cpu_in_panic()) 2850 + if (panic_on_other_cpu()) 2840 2851 return 0; 2841 2852 if (down_trylock_console_sem()) 2842 2853 return 0; ··· 3216 3227 any_progress = true; 3217 3228 3218 3229 /* Allow panic_cpu to take over the consoles safely. */ 3219 - if (other_cpu_in_panic()) 3230 + if (panic_on_other_cpu()) 3220 3231 goto abandon; 3221 3232 3222 3233 if (do_cond_resched)