Messages in this thread | | | Date | Wed, 12 Jul 2023 01:07:58 +0900 | From | Sergey Senozhatsky <> | Subject | Re: [PATCH printk v2 2/5] printk: Add NMI safety to console_flush_on_panic() and console_unblank() |
| |
On (23/07/11 17:43), Petr Mladek wrote: > On Mon 2023-07-10 15:51:21, John Ogness wrote: > > The printk path is NMI safe because it only adds content to the > > buffer and then triggers the delayed output via irq_work. If the > > console is flushed or unblanked on panic (from NMI context) then it > > can deadlock in down_trylock_console_sem() because the semaphore is > > not NMI safe. > > <thinking loudly> > > Just to be sure. The semaphore is not NMI safe because even the > trylock takes an internal spin lock. Am I right, please? > > Alternative solution would be to make down_trylock() NMI safe > by using raw_spin_trylock_irqsave() for the internal lock. > > But this actually would not solve the whole problem. If the NMI safe > down_trylock() succeeded then up() would need to be called > in NMI as well. And up() really needs to take the spin lock > which might get blocked in the meantime.
I guess another problem with up() is that it also may call try_to_wake_up(), that may attempt to acquire a bunch of other spin_lock-s.
| |