From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergey Senozhatsky Subject: Re: [RFC][PATCHv2 3/4] serial: introduce uart_port locking helpers Date: Sat, 8 Dec 2018 12:12:49 +0900 Message-ID: <20181208031249.GA443@jagdpanzerIV> References: <20181016050428.17966-1-sergey.senozhatsky@gmail.com> <20181016050428.17966-4-sergey.senozhatsky@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20181016050428.17966-4-sergey.senozhatsky@gmail.com> Sender: linux-kernel-owner@vger.kernel.org To: Petr Mladek , Steven Rostedt , Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, Daniel Wang , Peter Zijlstra , Andrew Morton , Linus Torvalds , Alan Cox , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky , Sergey Senozhatsky List-Id: linux-serial@vger.kernel.org On (10/16/18 14:04), Sergey Senozhatsky wrote: [..] > - The first entry point is console ->write() callback, which we call > from printk(). A possible deadlock scenario there is: > > CPU0 > > spin_lock_irqsave(&port->lock, flags) << deadlock > serial_foo_write() > call_console_drivers() > console_unlock() > console_flush_on_panic() > panic() > > spin_lock_irqsave(&port->lock, flags) > serial_foo_write() > call_console_drivers() > console_unlock() > printk() > ... [..] > - The rest (of entry points) requires a bit different handling. > Let's take a look at the following backtrace: > > CPU0 > > spin_lock_irqsave(&port->lock, flags) << deadlock > serial_foo_write() > call_console_drivers() > console_unlock() > printk() > __queue_work() > tty_flip_buffer_push() > spin_lock_irqsave(&port->lock, flags) > serial_foo_handle_IRQ() > > > Serial drivers invoke tons of core kernel functions - WQ, MM, etc. All > of which may printk() in various cases. So we can't really just > "remove those printk-s". The simples way to address this seems to be > PRINTK_SAFE_CONTEXT_MASK. serial/UART and printk guys, sorry to bother you, do you hate this idea of removing console_driver->CORE KERNEL->printk->console_driver deadlock path? Or is there any chance we can move forward? -ss