From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50D80C433F5 for ; Thu, 6 Sep 2018 15:22:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E096120861 for ; Thu, 6 Sep 2018 15:22:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E096120861 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730290AbeIFT6g (ORCPT ); Thu, 6 Sep 2018 15:58:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:57654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729991AbeIFT6g (ORCPT ); Thu, 6 Sep 2018 15:58:36 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E304420659; Thu, 6 Sep 2018 15:22:34 +0000 (UTC) Date: Thu, 6 Sep 2018 11:22:33 -0400 From: Steven Rostedt To: Sergey Senozhatsky Cc: LKML , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Petr Mladek , Sergey Senozhatsky , "Paul E. McKenney" Subject: Re: [PATCH] printk/tracing: Do not trace printk_nmi_enter() Message-ID: <20180906112233.068d45a7@gandalf.local.home> In-Reply-To: <20180906023151.GA749@jagdpanzerIV> References: <20180905213334.03375777@vmware.local.home> <20180906023151.GA749@jagdpanzerIV> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 6 Sep 2018 11:31:51 +0900 Sergey Senozhatsky wrote: > Hello, > > On (09/05/18 21:33), Steven Rostedt wrote: > > do_idle { > > > > [interrupts enabled] > > > > [interrupts disabled] > > TRACE_IRQS_OFF [lockdep says irqs off] > > [...] > > TRACE_IRQS_IRET > > test if pt_regs say return to interrupts enabled [yes] > > TRACE_IRQS_ON [lockdep says irqs are on] > > > > > > nmi_enter() { > > printk_nmi_enter() [traced by ftrace] > > [ hit ftrace breakpoint ] > > > > TRACE_IRQS_OFF [lockdep says irqs off] > > [...] > > TRACE_IRQS_IRET [return from breakpoint] > > test if pt_regs say interrupts enabled [no] > > [iret back to interrupt] > > [iret back to code] > > > > tick_nohz_idle_enter() { > > > > lockdep_assert_irqs_enabled() [lockdep say no!] > > > > Although interrupts are indeed enabled, lockdep thinks it is not, and since > > we now do asserts via lockdep, it gives a false warning. The issue here is > > that printk_nmi_enter() is called before lockdep_off(), which disables > > lockdep (for this reason) in NMIs. By simply not allowing ftrace to see > > printk_nmi_enter() (via notrace annotation) we keep lockdep from getting > > confused. > > Great catch and I like the patch! > > Indeed, with printk_nmi we changed the "everything that nmi_enter does > should happen after lockdep_off" to "everything that nmi_enter does should > happen after printk_nmi_enter" // +similar change to nmi_exit. > > An alternative option, thus, could be re-instating back the rule that > lockdep_off/on should be the first and the last thing we do in > nmi_enter/nmi_exit. E.g. > > nmi_enter() > lockdep_off(); > printk_nmi_enter(); > > nmi_exit() > printk_nmi_exit(); > lockdep_on(); > > I guess that we can keep printk_nmi_enter/printk_nmi_exit at the top > and at the bottom of nmi_enter/nmi_exit correspondingly just in case > if lockdep_off/lockdep_on sometime in the future starts invoking printk(), > which would deadlock us. Hence I thought about doing the move first, but figured it wasn't needed, as Petr said, it's before ftrace_nmi_enter() and should be notrace regrardless. > > Acked-by: Sergey Senozhatsky > > > > Cc: stable@vger.kernel.org > > Fixes: 099f1c84c0052 ("printk: introduce per-cpu safe_print seq buffer") > > A minor nitpick, > > printk_nmi was introduced by 42a0bb3f71383b457 ("printk/nmi: generic > solution for safe printk in NMI") - in that commit we declared a new > printk_nmi_enter/exit should be the first and the last thing we do in > nmi_enter/nmi_exit rule. Thanks I'll update the change log. Grumble, my git blame foo is getting rusty. -- Steve