On 4/7/22 11:56, Petr Mladek wrote: > On Tue 2022-04-05 15:31:32, John Ogness wrote: >> Once kthread printing is available, console printing will no longer >> occur in the context of the printk caller. However, there are some >> special contexts where it is desirable for the printk caller to >> directly print out kernel messages. Using pr_flush() to wait for >> threaded printers is only possible if the caller is in a sleepable >> context and the kthreads are active. That is not always the case. >> >> Introduce printk_prefer_direct_enter() and printk_prefer_direct_exit() >> functions to explicitly (and globally) activate/deactivate preferred >> direct console printing. The term "direct console printing" refers to >> printing to all enabled consoles from the context of the printk >> caller. The term "prefer" is used because this type of printing is >> only best effort. If the console is currently locked or other >> printers are already actively printing, the printk caller will need >> to rely on the other contexts to handle the printing. >> >> This preferred direct printing is how all printing is currently >> handled (unless explicitly deferred). >> >> When kthread printing is introduced, there may be some unanticipated >> problems due to kthreads being unable to flush important messages. >> In order to minimize such risks, preferred direct printing is >> activated for the primary important messages when the system >> experiences general types of major errors. These are: >> >> - emergency reboot/shutdown >> - cpu and rcu stalls >> - hard and soft lockups >> - hung tasks >> - warn >> - sysrq I agree that those needs direct printing. Did you maybe checked how much (e.g. in percentage) of a normal log is then still left to be printed threadened? Just in case it's not much, is there still a benefit to introduce threadened printing? Or another example, e.g. when running on a slow console (the best testcase I know of is a 9600 baud serial port), where some printks are threadened. Then a warn printk() has to be shown, doesn't it mean all threadened printks have to be flushed (waited for) until the warning can be shown. Will there then still be a measureable time benefit? Just wondering... Helge