Re: consoles: was: [PATCH next v2 3/3] printk: remove logbuf_lock, add syslog_lock

From: Sergey Senozhatsky
Date: Fri Dec 04 2020 - 23:48:42 EST


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; 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()

-ss