Skip to content

Commit ab40681

Browse files
jognesspmladek
authored andcommitted
printk: remove @console_locked
The static global variable @console_locked is used to help debug VT code to make sure that certain code paths are running with the console_lock held. However, this information is also available with the static global variable @console_kthreads_blocked (for locking via console_lock()), and the static global variable @console_kthreads_active (for locking via console_trylock()). Remove @console_locked and update is_console_locked() to use the alternative variables. Signed-off-by: John Ogness <john.ogness@linutronix.de> Reviewed-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20220421212250.565456-16-john.ogness@linutronix.de
1 parent 8e27473 commit ab40681

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

kernel/printk/printk.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,7 @@ static void console_kthreads_unblock(void)
340340
console_kthreads_blocked = false;
341341
}
342342

343-
/*
344-
* This is used for debugging the mess that is the VT code by
345-
* keeping track if we have the console semaphore held. It's
346-
* definitely not the perfect debug tool (we don't know if _WE_
347-
* hold it and are racing, but it helps tracking those weird code
348-
* paths in the console code where we end up in places I want
349-
* locked without the console semaphore held).
350-
*/
351-
static int console_locked, console_suspended;
343+
static int console_suspended;
352344

353345
/*
354346
* Array of consoles built from command line options (console=)
@@ -2719,7 +2711,6 @@ void console_lock(void)
27192711
if (console_suspended)
27202712
return;
27212713
console_kthreads_block();
2722-
console_locked = 1;
27232714
console_may_schedule = 1;
27242715
}
27252716
EXPORT_SYMBOL(console_lock);
@@ -2744,15 +2735,26 @@ int console_trylock(void)
27442735
up_console_sem();
27452736
return 0;
27462737
}
2747-
console_locked = 1;
27482738
console_may_schedule = 0;
27492739
return 1;
27502740
}
27512741
EXPORT_SYMBOL(console_trylock);
27522742

2743+
/*
2744+
* This is used to help to make sure that certain paths within the VT code are
2745+
* running with the console lock held. It is definitely not the perfect debug
2746+
* tool (it is not known if the VT code is the task holding the console lock),
2747+
* but it helps tracking those weird code paths in the console code such as
2748+
* when the console is suspended: where the console is not locked but no
2749+
* console printing may occur.
2750+
*
2751+
* Note: This returns true when the console is suspended but is not locked.
2752+
* This is intentional because the VT code must consider that situation
2753+
* the same as if the console was locked.
2754+
*/
27532755
int is_console_locked(void)
27542756
{
2755-
return (console_locked || atomic_read(&console_kthreads_active));
2757+
return (console_kthreads_blocked || atomic_read(&console_kthreads_active));
27562758
}
27572759
EXPORT_SYMBOL(is_console_locked);
27582760

@@ -2808,8 +2810,6 @@ static inline bool console_is_usable(struct console *con)
28082810

28092811
static void __console_unlock(void)
28102812
{
2811-
console_locked = 0;
2812-
28132813
/*
28142814
* Depending on whether console_lock() or console_trylock() was used,
28152815
* appropriately allow the kthread printers to continue.
@@ -3127,7 +3127,6 @@ void console_unblank(void)
31273127
} else
31283128
console_lock();
31293129

3130-
console_locked = 1;
31313130
console_may_schedule = 0;
31323131
for_each_console(c)
31333132
if ((c->flags & CON_ENABLED) && c->unblank)

0 commit comments

Comments
 (0)