Skip to content

Commit 007eeab

Browse files
committed
Revert "printk: remove @console_locked"
This reverts commit ab40681. The testing of 5.19 release candidates revealed missing synchronization between early and regular console functionality. It would be possible to start the console kthreads later as a workaround. But it is clear that console lock serialized console drivers between each other. It opens a big area of possible problems that were not considered by people involved in the development and review. printk() is crucial for debugging kernel issues and console output is very important part of it. The number of consoles is huge and a proper review would take some time. As a result it need to be reverted for 5.19. Link: https://lore.kernel.org/r/YrBdjVwBOVgLfHyb@alley Signed-off-by: Petr Mladek <pmladek@suse.com> Link: https://lore.kernel.org/r/20220623145157.21938-4-pmladek@suse.com
1 parent 05c96b3 commit 007eeab

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

kernel/printk/printk.c

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

343-
static int console_suspended;
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;
344352

345353
/*
346354
* Array of consoles built from command line options (console=)
@@ -2711,6 +2719,7 @@ void console_lock(void)
27112719
if (console_suspended)
27122720
return;
27132721
console_kthreads_block();
2722+
console_locked = 1;
27142723
console_may_schedule = 1;
27152724
}
27162725
EXPORT_SYMBOL(console_lock);
@@ -2735,26 +2744,15 @@ int console_trylock(void)
27352744
up_console_sem();
27362745
return 0;
27372746
}
2747+
console_locked = 1;
27382748
console_may_schedule = 0;
27392749
return 1;
27402750
}
27412751
EXPORT_SYMBOL(console_trylock);
27422752

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-
*/
27552753
int is_console_locked(void)
27562754
{
2757-
return (console_kthreads_blocked || atomic_read(&console_kthreads_active));
2755+
return (console_locked || atomic_read(&console_kthreads_active));
27582756
}
27592757
EXPORT_SYMBOL(is_console_locked);
27602758

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

28112809
static void __console_unlock(void)
28122810
{
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,6 +3127,7 @@ void console_unblank(void)
31273127
} else
31283128
console_lock();
31293129

3130+
console_locked = 1;
31303131
console_may_schedule = 0;
31313132
for_each_console(c)
31323133
if ((c->flags & CON_ENABLED) && c->unblank)

0 commit comments

Comments
 (0)