From patchwork Tue Apr 6 11:12:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 49493 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8BDC7B7CF3 for ; Tue, 6 Apr 2010 21:12:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754217Ab0DFLMN (ORCPT ); Tue, 6 Apr 2010 07:12:13 -0400 Received: from bombadil.infradead.org ([18.85.46.34]:47770 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753146Ab0DFLMK (ORCPT ); Tue, 6 Apr 2010 07:12:10 -0400 Received: from e35131.upc-e.chello.nl ([213.93.35.131] helo=dyad.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.69 #1 (Red Hat Linux)) id 1Nz6hV-0005rR-Af for sparclinux@vger.kernel.org; Tue, 06 Apr 2010 11:12:09 +0000 Received: by dyad.programming.kicks-ass.net (Postfix, from userid 65534) id 216D98BF4; Tue, 6 Apr 2010 13:13:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on dyad X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=failed version=3.2.5 Received: from [IPv6:::1] (dyad [192.168.0.60]) by dyad.programming.kicks-ass.net (Postfix) with ESMTP id B809810BC2; Tue, 6 Apr 2010 13:13:33 +0200 (CEST) Subject: [RFC][PATCH] lockdep: WARN about local_irq_{en,dis}able in NMI context From: Peter Zijlstra To: David Miller Cc: fweisbec@gmail.com, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@elte.hu, acme@redhat.com, paulus@samba.org In-Reply-To: <20100406.025049.267615796.davem@davemloft.net> References: <20100405065701.GC5127@nowhere> <20100405.122233.188421941.davem@davemloft.net> <20100405194055.GA5265@nowhere> <20100406.025049.267615796.davem@davemloft.net> Date: Tue, 06 Apr 2010 13:12:01 +0200 Message-ID: <1270552321.1595.42.camel@laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org On Tue, 2010-04-06 at 02:50 -0700, David Miller wrote: > From: Frederic Weisbecker > Date: Mon, 5 Apr 2010 21:40:58 +0200 > > > It happens without CONFIG_FUNCTION_TRACER as well (but it happens > > when the function tracer runs). And I hadn't your > > perf_arch_save_caller_regs() when I triggered this. > > I figured out the problem, it's NMIs. As soon as I disable all of the > NMI watchdog code, the problem goes away. > > This is because some parts of the NMI interrupt handling path are not > marked with "notrace" and the various tracer code paths use > local_irq_disable() (either directly or indirectly) which doesn't work > with sparc64's NMI scheme. These essentially turn NMIs back on in the > NMI handler before the NMI condition has been cleared, and thus we can > re-enter with another NMI interrupt. > > We went through this for perf events, and we just made sure that > local_irq_{enable,disable}() never occurs in any of the code paths in > perf events that can be reached via the NMI interrupt handler. (the > only one we had was sched_clock() and that was easily fixed) One thing we can do is make the code WARN about this, how about something like the below --- Subject: lockdep: WARN about local_irq_{en,dis}able in NMI context Some architectures implement NMIs by using IRQ priority levels and mixing local_irq_{en,dis}able() with NMIs will give unexpected results. Hence disallow this in general and WARN about it. Signed-off-by: Peter Zijlstra --- kernel/lockdep.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/kernel/lockdep.c b/kernel/lockdep.c index 08e6f76..06ec1c7 100644 --- a/kernel/lockdep.c +++ b/kernel/lockdep.c @@ -2341,6 +2341,11 @@ EXPORT_SYMBOL(trace_hardirqs_on_caller); void trace_hardirqs_on(void) { + /* + * Some architectures can't deal with local_irq_{enable,disable} + * from NMI context (SPARC), enforce this. + */ + WARN_ON_ONCE(in_nmi()); trace_hardirqs_on_caller(CALLER_ADDR0); } EXPORT_SYMBOL(trace_hardirqs_on); @@ -2375,6 +2380,11 @@ EXPORT_SYMBOL(trace_hardirqs_off_caller); void trace_hardirqs_off(void) { + /* + * Some architectures can't deal with local_irq_{enable,disable} + * from NMI context (SPARC), enforce this. + */ + WARN_ON_ONCE(in_nmi()); trace_hardirqs_off_caller(CALLER_ADDR0); } EXPORT_SYMBOL(trace_hardirqs_off);