Skip to content

Commit 132a90d

Browse files
jognesspmladek
authored andcommitted
printk: Rename abandon_console_lock_in_panic() to other_cpu_in_panic()
Currently abandon_console_lock_in_panic() is only used to determine if the current CPU should immediately release the console lock because another CPU is in panic. However, later this function will be used by the CPU to immediately release other resources in this situation. Rename the function to other_cpu_in_panic(), which is a better description and does not assume it is related to the console lock. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20230717194607.145135-8-john.ogness@linutronix.de
1 parent 9e70a5e commit 132a90d

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

kernel/printk/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,5 @@ struct printk_message {
103103
u64 seq;
104104
unsigned long dropped;
105105
};
106+
107+
bool other_cpu_in_panic(void);

kernel/printk/printk.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,11 +2612,12 @@ static int console_cpu_notify(unsigned int cpu)
26122612
}
26132613

26142614
/*
2615-
* Return true when this CPU should unlock console_sem without pushing all
2616-
* messages to the console. This reduces the chance that the console is
2617-
* locked when the panic CPU tries to use it.
2615+
* Return true if a panic is in progress on a remote CPU.
2616+
*
2617+
* On true, the local CPU should immediately release any printing resources
2618+
* that may be needed by the panic CPU.
26182619
*/
2619-
static bool abandon_console_lock_in_panic(void)
2620+
bool other_cpu_in_panic(void)
26202621
{
26212622
if (!panic_in_progress())
26222623
return false;
@@ -2643,7 +2644,7 @@ void console_lock(void)
26432644
might_sleep();
26442645

26452646
/* On panic, the console_lock must be left to the panic cpu. */
2646-
while (abandon_console_lock_in_panic())
2647+
while (other_cpu_in_panic())
26472648
msleep(1000);
26482649

26492650
down_console_sem();
@@ -2663,7 +2664,7 @@ EXPORT_SYMBOL(console_lock);
26632664
int console_trylock(void)
26642665
{
26652666
/* On panic, the console_lock must be left to the panic cpu. */
2666-
if (abandon_console_lock_in_panic())
2667+
if (other_cpu_in_panic())
26672668
return 0;
26682669
if (down_trylock_console_sem())
26692670
return 0;
@@ -2978,7 +2979,7 @@ static bool console_flush_all(bool do_cond_resched, u64 *next_seq, bool *handove
29782979
any_progress = true;
29792980

29802981
/* Allow panic_cpu to take over the consoles safely. */
2981-
if (abandon_console_lock_in_panic())
2982+
if (other_cpu_in_panic())
29822983
goto abandon;
29832984

29842985
if (do_cond_resched)

0 commit comments

Comments
 (0)