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.

Revert "printk: remove @console_locked"

This reverts commit ab406816fca009349b89cbde885daf68a8c77e33.

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

+15 -14
+15 -14
kernel/printk/printk.c
··· 340 340 console_kthreads_blocked = false; 341 341 } 342 342 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; 344 352 345 353 /* 346 354 * Array of consoles built from command line options (console=) ··· 2719 2711 if (console_suspended) 2720 2712 return; 2721 2713 console_kthreads_block(); 2714 + console_locked = 1; 2722 2715 console_may_schedule = 1; 2723 2716 } 2724 2717 EXPORT_SYMBOL(console_lock); ··· 2744 2735 up_console_sem(); 2745 2736 return 0; 2746 2737 } 2738 + console_locked = 1; 2747 2739 console_may_schedule = 0; 2748 2740 return 1; 2749 2741 } 2750 2742 EXPORT_SYMBOL(console_trylock); 2751 2743 2752 - /* 2753 - * This is used to help to make sure that certain paths within the VT code are 2754 - * running with the console lock held. It is definitely not the perfect debug 2755 - * tool (it is not known if the VT code is the task holding the console lock), 2756 - * but it helps tracking those weird code paths in the console code such as 2757 - * when the console is suspended: where the console is not locked but no 2758 - * console printing may occur. 2759 - * 2760 - * Note: This returns true when the console is suspended but is not locked. 2761 - * This is intentional because the VT code must consider that situation 2762 - * the same as if the console was locked. 2763 - */ 2764 2744 int is_console_locked(void) 2765 2745 { 2766 - return (console_kthreads_blocked || atomic_read(&console_kthreads_active)); 2746 + return (console_locked || atomic_read(&console_kthreads_active)); 2767 2747 } 2768 2748 EXPORT_SYMBOL(is_console_locked); 2769 2749 ··· 2808 2810 2809 2811 static void __console_unlock(void) 2810 2812 { 2813 + console_locked = 0; 2814 + 2811 2815 /* 2812 2816 * Depending on whether console_lock() or console_trylock() was used, 2813 2817 * appropriately allow the kthread printers to continue. ··· 3127 3127 } else 3128 3128 console_lock(); 3129 3129 3130 + console_locked = 1; 3130 3131 console_may_schedule = 0; 3131 3132 for_each_console(c) 3132 3133 if ((c->flags & CON_ENABLED) && c->unblank)