public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-kernel@vger.kernel.org
Cc: "x86@kernel.org" <x86@kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Borislav Petkov <bp@amd64.org>, Tony Luck <tony.luck@gmail.com>
Subject: [PATCH 05/12] x86, mce: replace MCE_SELF_VECTOR by irq_work
Date: Wed, 08 Jun 2011 10:56:02 +0900	[thread overview]
Message-ID: <4DEED6B2.6080005@jp.fujitsu.com> (raw)
In-Reply-To: <4DEED509.1040504@jp.fujitsu.com>

MCE handler uses a special vector for self IPI to invoke post-emergency
processing in an interrupt context, e.g. calling NMI-unsafe function,
wakeup loggers and scheduling time-consuming work for recovery etc.

However this mechanism is now generalized by the following commit:

 > e360adbe29241a0194e10e20595360dd7b98a2b3
 > Author: Peter Zijlstra <a.p.zijlstra@chello.nl>
 > Date:   Thu Oct 14 14:01:34 2010 +0800
 >
 >  irq_work: Add generic hardirq context callbacks
 >
 >  Provide a mechanism that allows running code in IRQ context. It is
 >  most useful for NMI code that needs to interact with the rest of the
 >  system -- like wakeup a task to drain buffers.
 :

So change to use provided generic mechanism.

v2:
  update patch description

Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
 arch/x86/include/asm/entry_arch.h  |    4 ---
 arch/x86/include/asm/hw_irq.h      |    1 -
 arch/x86/include/asm/irq_vectors.h |    5 ----
 arch/x86/kernel/cpu/mcheck/mce.c   |   47 ++++-------------------------------
 arch/x86/kernel/entry_64.S         |    5 ----
 arch/x86/kernel/irqinit.c          |    3 --
 6 files changed, 6 insertions(+), 59 deletions(-)

diff --git a/arch/x86/include/asm/entry_arch.h b/arch/x86/include/asm/entry_arch.h
index 1cd6d26..0baa628 100644
--- a/arch/x86/include/asm/entry_arch.h
+++ b/arch/x86/include/asm/entry_arch.h
@@ -53,8 +53,4 @@ BUILD_INTERRUPT(thermal_interrupt,THERMAL_APIC_VECTOR)
 BUILD_INTERRUPT(threshold_interrupt,THRESHOLD_APIC_VECTOR)
 #endif
 
-#ifdef CONFIG_X86_MCE
-BUILD_INTERRUPT(mce_self_interrupt,MCE_SELF_VECTOR)
-#endif
-
 #endif
diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index bb9efe8..13f5504 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -34,7 +34,6 @@ extern void irq_work_interrupt(void);
 extern void spurious_interrupt(void);
 extern void thermal_interrupt(void);
 extern void reschedule_interrupt(void);
-extern void mce_self_interrupt(void);
 
 extern void invalidate_interrupt(void);
 extern void invalidate_interrupt0(void);
diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index 6e976ee..6665026 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -109,11 +109,6 @@
 
 #define UV_BAU_MESSAGE			0xf5
 
-/*
- * Self IPI vector for machine checks
- */
-#define MCE_SELF_VECTOR			0xf4
-
 /* Xen vector callback to receive events in a HVM domain */
 #define XEN_HVM_EVTCHN_CALLBACK		0xf3
 
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index ff1ae9b..e81d48b 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -10,7 +10,6 @@
 #include <linux/thread_info.h>
 #include <linux/capability.h>
 #include <linux/miscdevice.h>
-#include <linux/interrupt.h>
 #include <linux/ratelimit.h>
 #include <linux/kallsyms.h>
 #include <linux/rcupdate.h>
@@ -38,12 +37,9 @@
 #include <linux/mm.h>
 #include <linux/debugfs.h>
 #include <linux/edac_mce.h>
+#include <linux/irq_work.h>
 
 #include <asm/processor.h>
-#include <asm/hw_irq.h>
-#include <asm/apic.h>
-#include <asm/idle.h>
-#include <asm/ipi.h>
 #include <asm/mce.h>
 #include <asm/msr.h>
 
@@ -461,22 +457,13 @@ static inline void mce_get_rip(struct mce *m, struct pt_regs *regs)
 		m->ip = mce_rdmsrl(rip_msr);
 }
 
-#ifdef CONFIG_X86_LOCAL_APIC
-/*
- * Called after interrupts have been reenabled again
- * when a MCE happened during an interrupts off region
- * in the kernel.
- */
-asmlinkage void smp_mce_self_interrupt(struct pt_regs *regs)
+DEFINE_PER_CPU(struct irq_work, mce_irq_work);
+
+static void mce_irq_work_cb(struct irq_work *entry)
 {
-	ack_APIC_irq();
-	exit_idle();
-	irq_enter();
 	mce_notify_irq();
 	mce_schedule_work();
-	irq_exit();
 }
-#endif
 
 static void mce_report_event(struct pt_regs *regs)
 {
@@ -492,29 +479,7 @@ static void mce_report_event(struct pt_regs *regs)
 		return;
 	}
 
-#ifdef CONFIG_X86_LOCAL_APIC
-	/*
-	 * Without APIC do not notify. The event will be picked
-	 * up eventually.
-	 */
-	if (!cpu_has_apic)
-		return;
-
-	/*
-	 * When interrupts are disabled we cannot use
-	 * kernel services safely. Trigger an self interrupt
-	 * through the APIC to instead do the notification
-	 * after interrupts are reenabled again.
-	 */
-	apic->send_IPI_self(MCE_SELF_VECTOR);
-
-	/*
-	 * Wait for idle afterwards again so that we don't leave the
-	 * APIC in a non idle state because the normal APIC writes
-	 * cannot exclude us.
-	 */
-	apic_wait_icr_idle();
-#endif
+	irq_work_queue(&__get_cpu_var(mce_irq_work));
 }
 
 DEFINE_PER_CPU(unsigned, mce_poll_count);
@@ -1444,7 +1409,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
 	__mcheck_cpu_init_vendor(c);
 	__mcheck_cpu_init_timer();
 	INIT_WORK(&__get_cpu_var(mce_work), mce_process_work);
-
+	init_irq_work(&__get_cpu_var(mce_irq_work), &mce_irq_work_cb);
 }
 
 /*
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 8a445a0..9fa6546 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -991,11 +991,6 @@ apicinterrupt THRESHOLD_APIC_VECTOR \
 apicinterrupt THERMAL_APIC_VECTOR \
 	thermal_interrupt smp_thermal_interrupt
 
-#ifdef CONFIG_X86_MCE
-apicinterrupt MCE_SELF_VECTOR \
-	mce_self_interrupt smp_mce_self_interrupt
-#endif
-
 #ifdef CONFIG_SMP
 apicinterrupt CALL_FUNCTION_SINGLE_VECTOR \
 	call_function_single_interrupt smp_call_function_single_interrupt
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index f470e4e..f09d4bb 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -272,9 +272,6 @@ static void __init apic_intr_init(void)
 #ifdef CONFIG_X86_MCE_THRESHOLD
 	alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
 #endif
-#if defined(CONFIG_X86_MCE) && defined(CONFIG_X86_LOCAL_APIC)
-	alloc_intr_gate(MCE_SELF_VECTOR, mce_self_interrupt);
-#endif
 
 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
 	/* self generated IPI for local APIC timer */
-- 
1.7.1



  parent reply	other threads:[~2011-06-08  1:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-08  1:48 [PATCH 00/12] x86: minor cleanups/fixes for MCE codes (v2) Hidetoshi Seto
2011-06-08  1:51 ` [PATCH 01/12] mce-severity: fixes for mce severity table Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Fix two severities table signatures tip-bot for Tony Luck
2011-06-08  1:52 ` [PATCH 02/12] mce-severity: cleanup severity table, prep Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Make formatting a bit more readable tip-bot for Hidetoshi Seto
2011-06-08  1:53 ` [PATCH 03/12] mce-severity: cleanup severity table Hidetoshi Seto
2011-06-16 11:16   ` [tip:ras/core] x86, mce, severity: Cleanup " tip-bot for Hidetoshi Seto
2011-06-08  1:55 ` [PATCH 04/12] mce-severity: trivial cleanups Hidetoshi Seto
2011-06-16 11:17   ` [tip:ras/core] x86, mce, severity: Clean up trivial coding style problems tip-bot for Hidetoshi Seto
2011-06-08  1:56 ` Hidetoshi Seto [this message]
2011-06-16 11:17   ` [tip:ras/core] x86, mce: Replace MCE_SELF_VECTOR by irq_work tip-bot for Hidetoshi Seto
2011-06-08  1:56 ` [PATCH 06/12] x86, mce: replace MCM_ to MCI_MISC_ Hidetoshi Seto
2011-06-16 11:18   ` [tip:ras/core] x86, mce: Replace MCM_ with MCI_MISC_ tip-bot for Hidetoshi Seto
2011-06-08  1:57 ` [PATCH 07/12] x86, mce: introduce mce_gather_info() Hidetoshi Seto
2011-06-16 11:18   ` [tip:ras/core] x86, mce: Introduce mce_gather_info() tip-bot for Hidetoshi Seto
2011-06-08  1:58 ` [PATCH 08/12] x86, mce: check the result of ancient_init() Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Check " tip-bot for Hidetoshi Seto
2011-06-08  1:59 ` [PATCH 09/12] x86, mce: cleanup mce_create/remove_device Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Cleanup mce_create()/remove_device() tip-bot for Hidetoshi Seto
2011-06-08  2:00 ` [PATCH 10/12] x86, mce: cleanup mce_read Hidetoshi Seto
2011-06-16 11:19   ` [tip:ras/core] x86, mce: Cleanup mce_read() tip-bot for Hidetoshi Seto
2011-06-08  2:00 ` [PATCH 11/12] x86, mce: use prefix mce_chrdev_ to group functions Hidetoshi Seto
2011-06-16 11:20   ` [tip:ras/core] x86, mce: Use mce_chrdev_ prefix " tip-bot for Hidetoshi Seto
2011-06-08  2:02 ` [PATCH 12/12] x86, mce: use prefix mce_sysdev_ " Hidetoshi Seto
2011-06-16 11:20   ` [tip:ras/core] x86, mce: Use mce_sysdev_ prefix " tip-bot for Hidetoshi Seto
2011-06-08 10:19 ` [PATCH 00/12] x86: minor cleanups/fixes for MCE codes (v2) Borislav Petkov
2011-06-10  8:24   ` Hidetoshi Seto
  -- strict thread matches above, loose matches on Subject: below --
2011-05-27  4:00 [PATCH 00/12] minor cleanups/fixes for MCE codes Hidetoshi Seto
2011-05-27  4:07 ` [PATCH 05/12] x86, mce: replace MCE_SELF_VECTOR by irq_work Hidetoshi Seto

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=4DEED6B2.6080005@jp.fujitsu.com \
    --to=seto.hidetoshi@jp.fujitsu.com \
    --cc=bp@amd64.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tony.luck@gmail.com \
    --cc=x86@kernel.org \
    /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