From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754352AbbLJP0J (ORCPT ); Thu, 10 Dec 2015 10:26:09 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:34527 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751259AbbLJP0G (ORCPT ); Thu, 10 Dec 2015 10:26:06 -0500 Date: Fri, 11 Dec 2015 00:24:34 +0900 From: Sergey Senozhatsky To: Jan Kara Cc: Andrew Morton , Petr Mladek , KY Srinivasan , Steven Rostedt , linux-kernel@vger.kernel.org, Sergey Senozhatsky , Sergey Senozhatsky Subject: Re: [PATCH 1/7] printk: Hand over printing to console if printing too long Message-ID: <20151210152434.GF540@swordfish> References: <20151210145251.GA540@swordfish> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151210145251.GA540@swordfish> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (12/10/15 23:52), Sergey Senozhatsky wrote: > > I think we better use raw_spin_lock as a print_lock; and, apart from that, > seems that we don't re-init in zap_lock(). So I ended up with the following > patch on top of yours (to be folded): > > - use raw_spin_lock > - do not forget to re-init `print_lock' in zap_locks() while we are on this, what do you guys think? CPU1 CPU2 console_unlock() call_console_drivers() con->write() ... spin_lock ... uart, etc panic zap_lock() will raw_spin_lock_init(&logbuf_lock) and sema_init(&console_sem, 1), but we still have `spin_lock' held by con->write(). so the `panic' flush or print out will see con->write() being already blocked. ===8<==== We do zap_lock() in printk to make a panic print out possible, but we can end up having a locked serial console - e.g. panic has occurred whilst CPUx was in con->write(), which takes some internal locks, thus call_console_drivers() will perform con->write() on an already locked console. Try to reset() every console in zap_lock() via console specific ->reset() call. Signed-off-by: Sergey Senozhatsky --- include/linux/console.h | 1 + kernel/printk/printk.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/linux/console.h b/include/linux/console.h index bd19434..1cb8f72 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -125,6 +125,7 @@ struct console { void (*unblank)(void); int (*setup)(struct console *, char *); int (*match)(struct console *, char *name, int idx, char *options); + void (*reset)(struct console *); short flags; short index; int cflag; diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index f4a9565..ad172c4 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1580,6 +1580,7 @@ static void call_console_drivers(int level, */ static void zap_locks(void) { + struct console *c; static unsigned long oops_timestamp; if (time_after_eq(jiffies, oops_timestamp) && @@ -1589,6 +1590,11 @@ static void zap_locks(void) oops_timestamp = jiffies; debug_locks_off(); + + for_each_console(c) + if ((c->flags & CON_ENABLED) && c->reset) + c->reset(c); + /* If a crash is occurring, make sure we can't deadlock */ raw_spin_lock_init(&logbuf_lock); /* And make sure that we print immediately */ -- 2.6.3