From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752010AbdGESXu (ORCPT ); Wed, 5 Jul 2017 14:23:50 -0400 Received: from mail-oi0-f50.google.com ([209.85.218.50]:35168 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751692AbdGESXs (ORCPT ); Wed, 5 Jul 2017 14:23:48 -0400 MIME-Version: 1.0 In-Reply-To: <20170703142434.GV1538@pathway.suse.cz> References: <20170703142434.GV1538@pathway.suse.cz> From: Linus Torvalds Date: Wed, 5 Jul 2017 11:23:47 -0700 X-Google-Sender-Auth: jwYgcTP8X5JFE3j5T2xQMxXlZw8 Message-ID: Subject: Re: [GIT PULL] printk for 4.13 To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Peter Zijlstra , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 3, 2017 at 7:24 AM, Petr Mladek wrote: > > - Store printk() messages into the main log buffer directly even in NMI > when the lock is available. It is the best effort to print even large > chunk of text. It is handy, for example, when all ftrace messages > are printed during the system panic in NMI. No, this is entirely buggered. You can't just do raw_spin_is_locked(&logbuf_lock) to test whether you can get the logbuf_lock and then call vprintk_default(). It's not just about deadlock avoidance, the code will call things like down_trylock() on the console semaphore, and that operation is fundamentally not NMI-safe. The semaphore count is literally protected by a irq-safe (BUT NOT NMI-SAFE!) semaphore spinlock. So now you can instead deadlock just on the internal console semaphore spinlock (ie somebody is doing "console_lock()", NMI comes in, *BOOM*. Maybe I'm missing something, but I'm skipping this pull request as "completely broken". Linus