Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751411AbbEYMq7 (ORCPT ); Mon, 25 May 2015 08:46:59 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53532 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751203AbbEYMqq (ORCPT ); Mon, 25 May 2015 08:46:46 -0400 From: Petr Mladek To: Andrew Morton Cc: Frederic Weisbecker , Steven Rostedt , Dave Anderson , "Paul E. McKenney" , Kay Sievers , Jiri Kosina , Michal Hocko , Jan Kara , linux-kernel@vger.kernel.org, Wang Long , peifeiyue@huawei.com, dzickus@redhat.com, morgan.wang@huawei.com, sasha.levin@oracle.com, Petr Mladek Subject: [PATCH 00/10] printk: Avoid deadlock in NMI + vprintk_emit() cleanup Date: Mon, 25 May 2015 14:46:23 +0200 Message-Id: <1432557993-20458-1-git-send-email-pmladek@suse.cz> X-Mailer: git-send-email 1.8.5.6 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2307 Lines: 58 The main source of deadlocks caused by printk() in NMI context has been solved by the commit a9edc88093287 ("x86/nmi: Perform a safe NMI stack trace on all CPUs"). But there are still few warnings printed in the NMI code that could case a deadlock. For example, see the freeze discussed at https://lkml.org/lkml/2015/5/20/481 The warnings are not easy to avoid. We could not postpone them easily. We could not allocate buffers in NMI context. Therefore we would need some lockless mechanism to share a buffer between NMI and normal context. But this would make printk() code much more complicated and it is not worth it. There has already been an attempt to do so and it has been rejected, see https://lkml.org/lkml/2014/6/10/388 This patch set provides much easier solution. It prevents from the deadlock on logbuf_lock by using trylock rather than spin_lock. If the lock can not be taken, the message is ignored and some warning is printed later on. 1st patch adds the simple solution. 2nd, 4th, 5th patches makes the solution a bit more robust. 3rd patch just shuffle some code to make 4th patch trivial. 6th..10th patches split the spaghetti vprintk_emit() into more pieces. They basically just shuffle the code to make it better readable. The patch have been tested against Linus' tree but it can be applied also against linux-next. Petr Mladek (10): printk: Avoid deadlock in NMI context printk: Try harder to get logbuf_lock on NMI printk: Move the deferred printk stuff printk: Merge and flush NMI buffer predictably via IRQ work printk: Try hard to print Oops message in NMI context printk: Split delayed printing of warnings from vprintk_emit() printk: Split text formatting and analyze from vprintk_emit() printk: Detect scheduler messages in vprintk_format_and_analyze() printk: Split text storing logic from vprintk_emit() printk: Split console call from vprintk_emit() kernel/printk/printk.c | 378 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 269 insertions(+), 109 deletions(-) -- 1.8.5.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/