mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@in.ibm.com>
To: Morton Andrew Morton <akpm@osdl.org>,
	linux kernel mailing list <linux-kernel@vger.kernel.org>
Cc: Fastboot mailing list <fastboot@lists.osdl.org>,
	mingo@elte.hu, tglx@linutronix.de,
	"Eric W. Biederman" <ebiederm@xmission.com>
Subject: [RFC][PATCH 2.6.19-rc4-mm1] Check for clock event device handler being non NULL before calling it
Date: Thu, 2 Nov 2006 13:01:39 -0500	[thread overview]
Message-ID: <20061102180139.GC8074@in.ibm.com> (raw)


o Kdump broke in 2.6.19-rc4-mm1 on i386 due to LAPIC timer interrupt handling
  changes. (clock events)

o Problems happens because a pending LAPIC timer interrupt is received
  as soon as kernel enables interrupts first time during boot but 
  associated clock event device has not been initialized yet and
  kernel crashes.

o One can receive a pending LAPIC timer interrupt from previous kernel's
  context (as in kdump).  

o A pending LAPIC timer interrupt is delivedred to CPU in second kernel as
  soon as interrupts are enabled. Already idt vector has been set to handle
  LAPIC timer interrupts but actually LPAIC is setup in setup_local_APIC()
  much later. setup_local_APIC() also initializes LAPIC timer and in turn
  related clock_event_device. But here interrupts comes really early and LAPIC
  has not been set, associated clock_event_device structure has not been
  initialized hence kernel crashes in smp_apic_timer_interrupt().

o One of the possible solution is that register the LAPIC timer vector late
  after LAPIC has been initialized. But this would only solve the problem
  for boot cpu and not other cpus.

o In this patch, I check for clock_event_device event handler and if
  handler is NULL, that interrupt is ignored as spurious one. Not the best
  way to handle the situation as it does not count for bugs in
  clock_event_device creation and registration logic, and also introduces
  un-necessary check in fastpath. Pleaes suggest if there is a better way
  to handle this.

Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
---

 arch/i386/kernel/apic.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff -puN arch/i386/kernel/apic.c~debug1-patch arch/i386/kernel/apic.c
--- linux-2.6.19-rc4-reloc/arch/i386/kernel/apic.c~debug1-patch	2006-11-01 15:30:03.000000000 -0500
+++ linux-2.6.19-rc4-reloc-root/arch/i386/kernel/apic.c	2006-11-01 17:19:06.000000000 -0500
@@ -1322,6 +1322,23 @@ fastcall void smp_apic_timer_interrupt(s
 	int cpu = smp_processor_id();
 	struct clock_event_device *evt = &per_cpu(lapic_events, cpu);
 
+	/* Normally we should not be here till LAPIC has been initialized
+	 * but in some cases like kdump, its possible that there is a
+ 	 * pending LAPIC timer interrupt from previous kernel's context
+	 * and is delivered in new kernel the moment interrupts are enabled.
+	 *
+	 * Interrupts are enabled early and LAPIC is setup much later, hence
+	 * its possible that when we get here evt->event_handler is NULL.
+	 * Check for event_handler being NULL and discard the interrupt
+	 * as spurious.
+	 */
+
+	if (!evt->event_handler) {
+		printk("Spurious LAPIC timer interrupt on cpu %d\n", cpu);
+		set_irq_regs(old_regs);
+		return;
+	}
+
 	/*
 	 * the NMI deadlock-detector uses this.
 	 */
_

                 reply	other threads:[~2006-11-02 18:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20061102180139.GC8074@in.ibm.com \
    --to=vgoyal@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=fastboot@lists.osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®