All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add IRQ context simulation in mce-inject
@ 2011-09-19  9:14 Chen Gong
  2011-09-19 20:55 ` Andi Kleen
  0 siblings, 1 reply; 6+ messages in thread
From: Chen Gong @ 2011-09-19  9:14 UTC (permalink / raw)
  To: ak, Huang Ying; +Cc: Luck, Tony, linux-kernel

From: Chen Gong <gong.chen@linux.intel.com>

Current mce-inject can simulate some kinds of scenarios, such as
one CPU working in process context, and other CPUs working in NMI
context. To extend the coverage of test range, a new IRQ context
for other CPUs is added.

Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
---
  arch/x86/include/asm/mce.h              |    1 +
  arch/x86/kernel/cpu/mcheck/mce-inject.c |   34 +++++++++++++++++++++++++++---
  2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index c9321f3..2490e8c 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -54,6 +54,7 @@
  #define MCJ_CTX_IRQ		2    /* inject context: IRQ */
  #define MCJ_NMI_BROADCAST	4    /* do NMI broadcasting */
  #define MCJ_EXCEPTION		8    /* raise as exception */
+#define MCJ_IRQ_BRAODCAST	0x10 /* do IRQ broadcasting */
   /* Fields are zero when not available */
  struct mce {
diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c 
b/arch/x86/kernel/cpu/mcheck/mce-inject.c
index 0ed633c..8f7a119 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-inject.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c
@@ -17,6 +17,7 @@
  #include <linux/kernel.h>
  #include <linux/string.h>
  #include <linux/fs.h>
+#include <linux/preempt.h>
  #include <linux/smp.h>
  #include <linux/notifier.h>
  #include <linux/kdebug.h>
@@ -94,6 +95,18 @@ static int mce_raise_notify(struct notifier_block *self,
  	return NOTIFY_STOP;
  }
  +static void mce_irq_ipi(void *info)
+{
+	int cpu = smp_processor_id();
+	struct mce *m = &__get_cpu_var(injectm);
+
+	if (cpumask_test_cpu(cpu, mce_inject_cpumask) &&
+		m->inject_flags & MCJ_EXCEPTION) {
+		cpumask_clear_cpu(cpu, mce_inject_cpumask);
+		raise_exception(m, NULL);
+	}
+}
+
  static struct notifier_block mce_raise_nb = {
  	.notifier_call = mce_raise_notify,
  	.priority = NMI_LOCAL_NORMAL_PRIOR,
@@ -146,9 +159,10 @@ static void raise_mce(struct mce *m)
  		return;
   #ifdef CONFIG_X86_LOCAL_APIC
-	if (m->inject_flags & MCJ_NMI_BROADCAST) {
+	if (m->inject_flags & (MCJ_IRQ_BRAODCAST | MCJ_NMI_BROADCAST)) {
  		unsigned long start;
  		int cpu;
+
  		get_online_cpus();
  		cpumask_copy(mce_inject_cpumask, cpu_online_mask);
  		cpumask_clear_cpu(get_cpu(), mce_inject_cpumask);
@@ -158,13 +172,25 @@ static void raise_mce(struct mce *m)
  			    MCJ_CTX(mcpu->inject_flags) != MCJ_CTX_RANDOM)
  				cpumask_clear_cpu(cpu, mce_inject_cpumask);
  		}
-		if (!cpumask_empty(mce_inject_cpumask))
-			apic->send_IPI_mask(mce_inject_cpumask, NMI_VECTOR);
+		if (!cpumask_empty(mce_inject_cpumask)) {
+			if (m->inject_flags & MCJ_IRQ_BRAODCAST) {
+				/*
+				 * don't wait because mce_irq_ipi is necessary
+				 * to be sync with following raise_local
+				 */
+				preempt_disable();
+				smp_call_function_many(mce_inject_cpumask,
+					mce_irq_ipi, NULL, 0);
+				preempt_enable();
+			} else if (m->inject_flags & MCJ_NMI_BROADCAST)
+				apic->send_IPI_mask(mce_inject_cpumask,
+						NMI_VECTOR);
+		}
  		start = jiffies;
  		while (!cpumask_empty(mce_inject_cpumask)) {
  			if (!time_before(jiffies, start + 2*HZ)) {
  				printk(KERN_ERR
-				"Timeout waiting for mce inject NMI %lx\n",
+				"Timeout waiting for mce inject %lx\n",
  					*cpumask_bits(mce_inject_cpumask));
  				break;
  			}
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] add IRQ context simulation in mce-inject
  2011-09-19  9:14 [PATCH] add IRQ context simulation in mce-inject Chen Gong
@ 2011-09-19 20:55 ` Andi Kleen
  2011-10-21  5:32   ` Chen Gong
  0 siblings, 1 reply; 6+ messages in thread
From: Andi Kleen @ 2011-09-19 20:55 UTC (permalink / raw)
  To: Chen Gong; +Cc: Huang Ying, Luck, Tony, linux-kernel

On 9/19/2011 2:14 AM, Chen Gong wrote:
> From: Chen Gong <gong.chen@linux.intel.com>
>
> Current mce-inject can simulate some kinds of scenarios, such as
> one CPU working in process context, and other CPUs working in NMI
> context. To extend the coverage of test range, a new IRQ context
> for other CPUs is added.

Looks good to me.
-Andi


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add IRQ context simulation in mce-inject
  2011-09-19 20:55 ` Andi Kleen
@ 2011-10-21  5:32   ` Chen Gong
  0 siblings, 0 replies; 6+ messages in thread
From: Chen Gong @ 2011-10-21  5:32 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Huang Ying, Luck, Tony, linux-kernel

于 2011/9/20 4:55, Andi Kleen 写道:
> On 9/19/2011 2:14 AM, Chen Gong wrote:
>> From: Chen Gong <gong.chen@linux.intel.com>
>>
>> Current mce-inject can simulate some kinds of scenarios, such as
>> one CPU working in process context, and other CPUs working in NMI
>> context. To extend the coverage of test range, a new IRQ context
>> for other CPUs is added.
>
> Looks good to me.
> -Andi
>
> --

Hi, Andi

I will resend this patch, do you agree I add you as the "Signed-off-By"
in the next post?


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add IRQ context simulation in mce-inject
  2011-09-19  8:40 ` Chen Gong
@ 2011-09-19  9:14   ` Chen Gong
  0 siblings, 0 replies; 6+ messages in thread
From: Chen Gong @ 2011-09-19  9:14 UTC (permalink / raw)
  To: Kleen, Andi, Huang, Ying; +Cc: Luck, Tony, linux-kernel

please ignore this patch, I will re-send it right now

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] add IRQ context simulation in mce-inject
  2011-09-19  8:34 Chen, Gong
@ 2011-09-19  8:40 ` Chen Gong
  2011-09-19  9:14   ` Chen Gong
  0 siblings, 1 reply; 6+ messages in thread
From: Chen Gong @ 2011-09-19  8:40 UTC (permalink / raw)
  To: Chen, Gong; +Cc: Kleen, Andi, Huang, Ying, Luck, Tony, linux-kernel

于 2011/9/19 16:34, Chen, Gong 写道:
> Current mce-inject can simulate some kinds of scenarios, such as
> one CPU working in process context, and other CPUs working in NMI
> context. To extend the coverage of test range, a new IRQ context
> for other CPUs is added.
>
> Signed-off-by: Chen Gong<gong.chen@linux.intel.com>
> ---
>   arch/x86/include/asm/mce.h              |    1 +
>   arch/x86/kernel/cpu/mcheck/mce-inject.c |   34 +++++++++++++++++++++++++++---
>   2 files changed, 31 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
> index c9321f3..2490e8c 100644
> --- a/arch/x86/include/asm/mce.h
> +++ b/arch/x86/include/asm/mce.h
> @@ -54,6 +54,7 @@
>   #define MCJ_CTX_IRQ		2    /* inject context: IRQ */
>   #define MCJ_NMI_BROADCAST	4    /* do NMI broadcasting */
>   #define MCJ_EXCEPTION		8    /* raise as exception */
> +#define MCJ_IRQ_BRAODCAST	0x10 /* do IRQ broadcasting */
>
>   /* Fields are zero when not available */
>   struct mce {
> diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c b/arch/x86/kernel/cpu/mcheck/mce-inject.c
> index 0ed633c..8f7a119 100644
> --- a/arch/x86/kernel/cpu/mcheck/mce-inject.c
> +++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c
> @@ -17,6 +17,7 @@
>   #include<linux/kernel.h>
>   #include<linux/string.h>
>   #include<linux/fs.h>
> +#include<linux/preempt.h>
>   #include<linux/smp.h>
>   #include<linux/notifier.h>
>   #include<linux/kdebug.h>
> @@ -94,6 +95,18 @@ static int mce_raise_notify(struct notifier_block *self,
>   	return NOTIFY_STOP;
>   }
>
> +static void mce_irq_ipi(void *info)
> +{
> +	int cpu = smp_processor_id();
> +	struct mce *m =&__get_cpu_var(injectm);
> +
> +	if (cpumask_test_cpu(cpu, mce_inject_cpumask)&&
> +		m->inject_flags&  MCJ_EXCEPTION) {
> +		cpumask_clear_cpu(cpu, mce_inject_cpumask);
> +		raise_exception(m, NULL);
> +	}
> +}
> +
>   static struct notifier_block mce_raise_nb = {
>   	.notifier_call = mce_raise_notify,
>   	.priority = NMI_LOCAL_NORMAL_PRIOR,
> @@ -146,9 +159,10 @@ static void raise_mce(struct mce *m)
>   		return;
>
>   #ifdef CONFIG_X86_LOCAL_APIC
> -	if (m->inject_flags&  MCJ_NMI_BROADCAST) {
> +	if (m->inject_flags&  (MCJ_IRQ_BRAODCAST | MCJ_NMI_BROADCAST)) {
>   		unsigned long start;
>   		int cpu;
> +
>   		get_online_cpus();
>   		cpumask_copy(mce_inject_cpumask, cpu_online_mask);
>   		cpumask_clear_cpu(get_cpu(), mce_inject_cpumask);
> @@ -158,13 +172,25 @@ static void raise_mce(struct mce *m)
>   			    MCJ_CTX(mcpu->inject_flags) != MCJ_CTX_RANDOM)
>   				cpumask_clear_cpu(cpu, mce_inject_cpumask);
>   		}
> -		if (!cpumask_empty(mce_inject_cpumask))
> -			apic->send_IPI_mask(mce_inject_cpumask, NMI_VECTOR);
> +		if (!cpumask_empty(mce_inject_cpumask)) {
> +			if (m->inject_flags&  MCJ_IRQ_BRAODCAST) {
> +				/*
> +				 * don't wait because mce_irq_ipi is necessary
> +				 * to be sync with following raise_local
> +				 */
> +				preempt_disable();
> +				smp_call_function_many(mce_inject_cpumask,
> +					mce_irq_ipi, NULL, 0);
> +				preempt_enable();
> +			} else if (m->inject_flags&  MCJ_NMI_BROADCAST)
> +				apic->send_IPI_mask(mce_inject_cpumask,
> +						NMI_VECTOR);
> +		}
>   		start = jiffies;
>   		while (!cpumask_empty(mce_inject_cpumask)) {
>   			if (!time_before(jiffies, start + 2*HZ)) {
>   				printk(KERN_ERR
> -				"Timeout waiting for mce inject NMI %lx\n",
> +				"Timeout waiting for mce inject %lx\n",
>   					*cpumask_bits(mce_inject_cpumask));
>   				break;
>   			}
> -- 1.7.1
>
> N�����r��y���b�X��ǧv�^�)޺{.n�+����{����zX��\x17��ܨ}���Ơz�&j:+v���\a����zZ+��+zf���h���~����i���z�\x1e�w���?����&�)ߢ^[f��^jǫy�m��@A�a��\x7f�\f0��h�\x0f�i\x7f

My mailstop meets some trouble, please forgive me for sending this patch 
via outlook :-(

send

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] add IRQ context simulation in mce-inject
@ 2011-09-19  8:34 Chen, Gong
  2011-09-19  8:40 ` Chen Gong
  0 siblings, 1 reply; 6+ messages in thread
From: Chen, Gong @ 2011-09-19  8:34 UTC (permalink / raw)
  To: Kleen, Andi, Huang, Ying; +Cc: Luck, Tony, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 3421 bytes --]

Current mce-inject can simulate some kinds of scenarios, such as
one CPU working in process context, and other CPUs working in NMI
context. To extend the coverage of test range, a new IRQ context
for other CPUs is added.

Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
---
 arch/x86/include/asm/mce.h              |    1 +
 arch/x86/kernel/cpu/mcheck/mce-inject.c |   34 +++++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/mce.h b/arch/x86/include/asm/mce.h
index c9321f3..2490e8c 100644
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -54,6 +54,7 @@
 #define MCJ_CTX_IRQ		2    /* inject context: IRQ */
 #define MCJ_NMI_BROADCAST	4    /* do NMI broadcasting */
 #define MCJ_EXCEPTION		8    /* raise as exception */
+#define MCJ_IRQ_BRAODCAST	0x10 /* do IRQ broadcasting */
 
 /* Fields are zero when not available */
 struct mce {
diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c b/arch/x86/kernel/cpu/mcheck/mce-inject.c
index 0ed633c..8f7a119 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-inject.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c
@@ -17,6 +17,7 @@
 #include <linux/kernel.h>
 #include <linux/string.h>
 #include <linux/fs.h>
+#include <linux/preempt.h>
 #include <linux/smp.h>
 #include <linux/notifier.h>
 #include <linux/kdebug.h>
@@ -94,6 +95,18 @@ static int mce_raise_notify(struct notifier_block *self,
 	return NOTIFY_STOP;
 }
 
+static void mce_irq_ipi(void *info)
+{
+	int cpu = smp_processor_id();
+	struct mce *m = &__get_cpu_var(injectm);
+
+	if (cpumask_test_cpu(cpu, mce_inject_cpumask) &&
+		m->inject_flags & MCJ_EXCEPTION) {
+		cpumask_clear_cpu(cpu, mce_inject_cpumask);
+		raise_exception(m, NULL);
+	}
+}
+
 static struct notifier_block mce_raise_nb = {
 	.notifier_call = mce_raise_notify,
 	.priority = NMI_LOCAL_NORMAL_PRIOR,
@@ -146,9 +159,10 @@ static void raise_mce(struct mce *m)
 		return;
 
 #ifdef CONFIG_X86_LOCAL_APIC
-	if (m->inject_flags & MCJ_NMI_BROADCAST) {
+	if (m->inject_flags & (MCJ_IRQ_BRAODCAST | MCJ_NMI_BROADCAST)) {
 		unsigned long start;
 		int cpu;
+
 		get_online_cpus();
 		cpumask_copy(mce_inject_cpumask, cpu_online_mask);
 		cpumask_clear_cpu(get_cpu(), mce_inject_cpumask);
@@ -158,13 +172,25 @@ static void raise_mce(struct mce *m)
 			    MCJ_CTX(mcpu->inject_flags) != MCJ_CTX_RANDOM)
 				cpumask_clear_cpu(cpu, mce_inject_cpumask);
 		}
-		if (!cpumask_empty(mce_inject_cpumask))
-			apic->send_IPI_mask(mce_inject_cpumask, NMI_VECTOR);
+		if (!cpumask_empty(mce_inject_cpumask)) {
+			if (m->inject_flags & MCJ_IRQ_BRAODCAST) {
+				/*
+				 * don't wait because mce_irq_ipi is necessary
+				 * to be sync with following raise_local
+				 */
+				preempt_disable();
+				smp_call_function_many(mce_inject_cpumask,
+					mce_irq_ipi, NULL, 0);
+				preempt_enable();
+			} else if (m->inject_flags & MCJ_NMI_BROADCAST)
+				apic->send_IPI_mask(mce_inject_cpumask,
+						NMI_VECTOR);
+		}
 		start = jiffies;
 		while (!cpumask_empty(mce_inject_cpumask)) {
 			if (!time_before(jiffies, start + 2*HZ)) {
 				printk(KERN_ERR
-				"Timeout waiting for mce inject NMI %lx\n",
+				"Timeout waiting for mce inject %lx\n",
 					*cpumask_bits(mce_inject_cpumask));
 				break;
 			}
-- 1.7.1

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-21  5:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-19  9:14 [PATCH] add IRQ context simulation in mce-inject Chen Gong
2011-09-19 20:55 ` Andi Kleen
2011-10-21  5:32   ` Chen Gong
  -- strict thread matches above, loose matches on Subject: below --
2011-09-19  8:34 Chen, Gong
2011-09-19  8:40 ` Chen Gong
2011-09-19  9:14   ` Chen Gong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.