From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754938AbcJSEdg (ORCPT ); Wed, 19 Oct 2016 00:33:36 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36033 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751292AbcJSEda (ORCPT ); Wed, 19 Oct 2016 00:33:30 -0400 Date: Wed, 19 Oct 2016 13:33:25 +0900 From: Sergey Senozhatsky To: Sergey Senozhatsky Cc: Petr Mladek , Andrew Morton , Jan Kara , Tejun Heo , Calvin Owens , Thomas Gleixner , Mel Gorman , Steven Rostedt , Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC][PATCHv3 0/6] printk: use printk_safe to handle printk() recursive calls Message-ID: <20161019043325.GA444@swordfish> References: <20161018154045.7364-1-sergey.senozhatsky@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161018154045.7364-1-sergey.senozhatsky@gmail.com> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (10/19/16 00:40), Sergey Senozhatsky wrote: [..] > Deadlock scenarios that printk_safe can handle: > > a) printk recursion from logbuf_lock spin_lock section in printk() > printk() > raw_spin_lock(&logbuf_lock); > WARN_ON(1); > raw_spin_unlock(&logbuf_lock); > > b) printk from sem->lock spin_lock section > printk() > console_trylock() > down_trylock() > raw_spin_lock_irqsave(&sem->lock, flags); > WARN_ON(1); > raw_spin_unlock_irqrestore(&sem->lock, flags); > > c) printk from logbuf_lock spin_lock section in console_unlock() > printk() > console_unlock() > raw_spin_lock(&logbuf_lock); > WARN_ON(1); > raw_spin_unlock(&logbuf_lock); > > d) printk from ->pi_lock from semaphore up > printk() > console_unlock() > up() > try_to_wake_up() > raw_spin_lock_irqsave(&p->pi_lock, flags); > WARN_ON(1); > raw_spin_unlock_irqrestore(&p->pi_lock, flags); and e) anything from call_console_drivers() should be fine as well. console_unlock() big printing loop is covered by printk_safe, need to protect console_cont_flush()->call_console_drivers(). so printk "direct path" seems to be safe now: printk -> .. -> console_unlock() -> call_console_drivers() -> serial_console_write() anything that is "indirect" is not covered in this patch set. -ss