public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: Don Zickus <dzickus@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>,
	"Mingarelli, Thomas" <Thomas.Mingarelli@hp.com>,
	Andi Kleen <andi@firstfloor.org>,
	Prarit Bhargava <prarit@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"arozansk@redhat.com" <arozansk@redhat.com>,
	"ak@linux.intel.com" <ak@linux.intel.com>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: [PATCH RFC] NMI Re-introduce un[set]_nmi_callback
Date: Fri, 5 Sep 2008 12:24:16 +0200	[thread overview]
Message-ID: <20080905102416.GA11212@elte.hu> (raw)
In-Reply-To: <20080904212453.GR3400@redhat.com>


* Don Zickus <dzickus@redhat.com> wrote:

> Prarit's patch disabled the timer upon registering a callback to 
> prevent this case.  The thought was if you have your own handler you 
> could provide your own watchdog.

btw., while we are talking about watchdog design problems, the current 
way the NMI timer watchdog oprofile fallback uses the die handler and 
how it all interacts with the ioapic/lapic-timer NMI watchdog is 
misdesigned as well. (this is used in the relatively rare but still 
possible case where no primary oprofile handler is found and installed)

The i386 and x86_64 architecture code started using die notifiers for 
the NMI timer watchdog oprofile code two years ago, via commit 2fbe7b25 
"i386/x86-64: Remove un/set_nmi_callback and reserve/release_lapic_nmi 
functions". [ Hey - what a coincidence - that was done by you! ;-) ]

It was a nice cleanup but not complete: using a die notifier for the NMI 
watchdog does not work properly as the NMI watchdog driver has no 
knowledge currently about whether it got activated (often it's not even 
possible to tell it):

 +       case DIE_NMI:
 +               oprofile_add_sample(args->regs, 0);
 +               ret = NOTIFY_STOP;
 +               break;

it always returns NOTIFY_STOP. That breaks all other lower prio 
notifiers down the chain which might have proper knowledge about the 
source of the NMI. Such kind of cross-notifier breakage is one of the 
reasons why driver notifiers try to become exclusive and try to play 
tricks with the nmi watchdog.

Instead the full solution would be for it to return NOTIFY_OK when it is 
not the source of the NMI (and is able to tell it).

[
  The reason why i qualified my statement with "when it is able to tell 
  it" is that while it is possible to disambiguate the NMI source when 
  the source of the NMI was the local apic timer (we already do that in 
  lapic_wd_event() - we return 1 if we rearmed the counter in the CPU), 
  it is not possible to tell it reliably that the NMI source was the
  IO-APIC.

  The reason for that is that the IO-APIC generated NMIs are 
  fundamentally 'anonymous' in that case: we put the legacy PIC into 
  auto-EOI mode and the IO-APIC broadcasts the NMIs and they are edge 
  triggered (on all but some really ancient systems) . So there's no 
  permanent and reliable information left about why the NMI was raised 
  in the CPU. This is a property of the hardware, we cannot solve it on 
  the kernel side. (we tried explicit ACKs before, and those are even 
  worse.)
]

So the right long-term solution is to move all NMI watchdog code 
(including the lockup detection bits - nmi_watchdog_tick(), etc.) into 
the notifier, then to propagate the re-arm information from 
lapic_wd_event() back into the notifier return code, and perhaps to 
print a (one-time) warning into the kernel log about the (in essence) 
deactivated lower-prio notifiers when the IO-APIC watchdog is activated.

This is all non-default debug or instrumentation functionality so if 
they cancel out each other in certain rare cases that's not a big issue 
in practice, as long as the user is informed about the constraints.

	Ingo

  parent reply	other threads:[~2008-09-05 10:25 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-04 13:07 [PATCH RFC] NMI Re-introduce un[set]_nmi_callback Prarit Bhargava
2008-09-04 13:37 ` Peter Zijlstra
2008-09-04 14:29   ` Prarit Bhargava
2008-09-04 14:49     ` aris
2008-09-04 14:56     ` Ingo Molnar
2008-09-04 15:12       ` H. Peter Anvin
2008-09-04 15:18         ` Ingo Molnar
2008-09-04 15:52       ` Andi Kleen
2008-09-04 17:20         ` Don Zickus
2008-09-04 17:52           ` Andi Kleen
2008-09-04 18:26             ` Don Zickus
2008-09-04 18:47               ` Andi Kleen
2008-09-04 19:08               ` Vivek Goyal
2008-09-04 20:00                 ` Andi Kleen
2008-09-04 20:01                   ` Mingarelli, Thomas
2008-09-04 20:19                     ` Andi Kleen
2008-09-04 20:21                       ` Mingarelli, Thomas
2008-09-04 20:53                         ` Andi Kleen
2008-09-04 21:22                           ` Don Zickus
2008-09-04 20:57                     ` Vivek Goyal
2008-09-04 21:05                       ` Mingarelli, Thomas
2008-09-04 21:21                         ` Vivek Goyal
2008-09-04 21:24                           ` Don Zickus
2008-09-04 21:46                             ` Vivek Goyal
2008-09-05  8:57                               ` Ingo Molnar
2008-09-05 10:24                             ` Ingo Molnar [this message]
2008-09-05  9:33                   ` Ingo Molnar
2008-09-05 14:16                     ` Vivek Goyal
2008-09-05 14:18                     ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080905102416.GA11212@elte.hu \
    --to=mingo@elte.hu \
    --cc=Thomas.Mingarelli@hp.com \
    --cc=ak@linux.intel.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andi@firstfloor.org \
    --cc=arozansk@redhat.com \
    --cc=dzickus@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=macro@linux-mips.org \
    --cc=peterz@infradead.org \
    --cc=prarit@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox