On Sat 2020-12-05 13:39:53, Sergey Senozhatsky wrote: > On (20/12/04 17:19), Petr Mladek wrote: > [..] > > > --- a/kernel/printk/printk.c > > > +++ b/kernel/printk/printk.c > > > @@ -2432,7 +2490,6 @@ void console_unlock(void) > > > size_t len; > > > > > > printk_safe_enter_irqsave(flags); > > > > Why do we actually need to use the printk_safe context here? > > There is not longer a risk of deadlock caused by logbuf_lock. > > All other recursions should be prevented by console_trylock() > > in printk(). > > All semaphore functions, including down_trylock(), acquire > semaphore spin_lock;
This has a very easy solution. The patch adds a code that counts recursion level. We just must not call console_trylock() when being inside a recursive printk. printk_safe() has two functions: 1. It allows to store messages a lockless way. This is obsoleted by the lockless ringbuffer. 2. It prevents calling consoles. We could move this check into vprintk_store(). We already have there similar check for printk_deferred(). > and then some call into the scheduler > (or other kernel core functions) under semaphore's spin_lock. > For instance > > up() > raw_spin_lock_irqsave(&sem->lock) > __up() > wake_up_process() > try_to_wake_up() This problem is partly solved by printk_deferred(). In each case, printk_safe() does not help here. I still do _not_ see a reason to keep printk_safe()! Best Regards, Petr