Skip to contentSkip to conversation

Add mce_ser interface in /sys/kernel/debug/mce/ for test

PATCH In review Jin Dongming 2 participants 3 messages Oct 29, 2010 – Nov 1, 2010 x86

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 Add mce_ser interface in /sys/kernel/debug/mce/ for test

If we want to test the part of mce handler for SRAO and SRAR, we need to have a test machine whose CPU supports MCG_SER_P. If we don't have such machine, we can not test the part of mce handler for SRAO and SRAR.

With this interface we can test the part of mce handler for SRAO and SRAR by setting mce_ser 1 on the machine which does not support MCG_SER_P.

Usage:
if val == 1 or val == 0
Set val to mce_ser.
else
Ser the original value to mce_ser.

Note:
Please don't use mce_ser interface except mce test. Because when the real mce exception happened, the unsuitable set with this interface maybe change the real process of mce handler and lead to a different result.

This patch is tested on Intel64 on next-tree.

---
 arch/x86/kernel/cpu/mcheck/mce.c |   39 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +39 -0
index 8edb04d..ed10e76 100644
@@ -2158,6 +2158,8 @@ static int __init mcheck_disable(char *str)
 __setup("nomce", mcheck_disable);
 
 #ifdef CONFIG_DEBUG_FS
+static int org_mce_ser;
+
 struct dentry *mce_get_debugfs_dir(void)
 {
 	static struct dentry *dmce;
@@ -2193,9 +2195,39 @@ static int fake_panic_set(void *data, u64 val)
 DEFINE_SIMPLE_ATTRIBUTE(fake_panic_fops, fake_panic_get,
 			fake_panic_set, "%llu\n");
 
+/*
+ * mce_ser_get() can only get the current value of mce_ser. 
+ * The value may be not the original value of mce_ser on this machine.
+ * So please use mce_ser_set() to confirm the original value of mce_ser.
+ */
+static int mce_ser_get(void *data, u64 *val)
+{
+	*val = mce_ser;
+	return 0;
+}
+
+/* 
+ * Set the value of mce_ser with mce_ser_set().
+ * Parameter "u64 val" of mce_ser_set() :
+ *      val == 1 or 0 : mce_ser = val;
+ *      others        : set mce_ser with the original value of mce_ser.
+ */
+static int mce_ser_set(void *data, u64 val)
+{
+	if (val == 1 || val == 0)
+		mce_ser = val;
+	else
+		mce_ser = org_mce_ser;
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(mce_ser_fops, mce_ser_get,
+			mce_ser_set, "%llu\n");
+
 static int __init mcheck_debugfs_init(void)
 {
 	struct dentry *dmce, *ffake_panic;
+	struct dentry *fmce_ser = NULL;
 
 	dmce = mce_get_debugfs_dir();
 	if (!dmce)
@@ -2205,6 +2237,13 @@ static int __init mcheck_debugfs_init(void)
 	if (!ffake_panic)
 		return -ENOMEM;
 
+	org_mce_ser = mce_ser;
+
+	fmce_ser = debugfs_create_file("mce_ser", 0644, dmce, NULL,
+						&mce_ser_fops);
+	if (!fmce_ser)
+		return -ENOMEM;
+
 	return 0;
 }
 late_initcall(mcheck_debugfs_init);
#1 lore raw
Quoted 13 lines · Jin Dongming

If we want to test the part of mce handler for SRAO and SRAR, we need to have a test machine whose CPU supports MCG_SER_P. If we don't have such machine, we can not test the part of mce handler for SRAO and SRAR.

With this interface we can test the part of mce handler for SRAO and SRAR by setting mce_ser 1 on the machine which does not support MCG_SER_P.

Usage:
if val == 1 or val == 0
Set val to mce_ser.
else
Ser the original value to mce_ser.

Quoted 5 lines

Note:
Please don't use mce_ser interface except mce test. Because when the real mce exception happened, the unsuitable set with this interface maybe change the real process of mce handler and lead to a different result.

Basic idea is good (I have been using a similar patch for quite some time). My patch was a little bit simpler though, not bothering with org_ser:

---

MCE: Add an debugfs interface to force MCA recovery

This is useful to run the MCA recovery test cases using error injection on a non MCA recovery capable system.

On a system without MCA recovery this should be a nop.

---
 arch/x86/kernel/cpu/mcheck/mce.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mcheck/mce.c +18 -2
Index: linux/arch/x86/kernel/cpu/mcheck/mce.c
===================================================================
@@ -2346,13 +2346,26 @@ static int fake_panic_set(void *data, u6
 	fake_panic = val;
 	return 0;
 }
+static int mca_recovery_get(void *data, u64 *val)
+{
+	*val = mce_ser;
+	return 0;
+}
+
+static int mca_recovery_set(void *data, u64 val)
+{
+	mce_ser = val;
+	return 0;
+}
 
 DEFINE_SIMPLE_ATTRIBUTE(fake_panic_fops, fake_panic_get,
 			fake_panic_set, "%llu\n");
+DEFINE_SIMPLE_ATTRIBUTE(mca_recovery_fops, mca_recovery_get,
+			mca_recovery_set, "%llu\n");
 
 static int __init mcheck_debugfs_init(void)
 {
-	struct dentry *dmce, *ffake_panic;
+	struct dentry *dmce, *ffake_panic, *fmca_recovery;
 
 	dmce = mce_get_debugfs_dir();
 	if (!dmce)
@@ -2361,7 +2374,10 @@ static int __init mcheck_debugfs_init(vo
 					  &fake_panic_fops);
 	if (!ffake_panic)
 		return -ENOMEM;
-
+	fmca_recovery = debugfs_create_file("mca_recovery_force",0644,dmce,NULL,
+					&mca_recovery_fops);
+	if (!fmca_recovery)
+		return -ENOMEM;
 	return 0;
 }
 late_initcall(mcheck_debugfs_init);
#2 lore raw
Quoted 14 lines · Andi Kleen
Quoted 13 lines · Jin Dongming

If we want to test the part of mce handler for SRAO and SRAR, we need to have a test machine whose CPU supports MCG_SER_P. If we don't have such machine, we can not test the part of mce handler for SRAO and SRAR.

With this interface we can test the part of mce handler for SRAO and SRAR by setting mce_ser 1 on the machine which does not support MCG_SER_P.

Usage:
if val == 1 or val == 0
Set val to mce_ser.
else
Ser the original value to mce_ser.

Quoted 9 lines
Quoted 5 lines

Note:
Please don't use mce_ser interface except mce test. Because when the real mce exception happened, the unsuitable set with this interface maybe change the real process of mce handler and lead to a different result.

Basic idea is good (I have been using a similar patch for quite some time). My patch was a little bit simpler though, not bothering with org_ser:

Yes, it is.

But if you set mce_ser with mca_recovery_set(), the original value of mce_ser will be changed, is it right?

If a new guy try to test mce with the test machine, he/she may be confused by the value of mce_ser. So I think how to tell him the original value is also important.

Quoted 66 lines

---

MCE: Add an debugfs interface to force MCA recovery

This is useful to run the MCA recovery test cases using error injection on a non MCA recovery capable system.

On a system without MCA recovery this should be a nop.

---
 arch/x86/kernel/cpu/mcheck/mce.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

Index: linux/arch/x86/kernel/cpu/mcheck/mce.c
===================================================================

arch/x86/kernel/cpu/mcheck/mce.c +18 -3
@@ -2346,13 +2346,26 @@ static int fake_panic_set(void *data, u6
 	fake_panic = val;
 	return 0;
 }
+static int mca_recovery_get(void *data, u64 *val)
+{
+	*val = mce_ser;
+	return 0;
+}
+
+static int mca_recovery_set(void *data, u64 val)
+{
+	mce_ser = val;
+	return 0;
+}
 
 DEFINE_SIMPLE_ATTRIBUTE(fake_panic_fops, fake_panic_get,
 			fake_panic_set, "%llu\n");
+DEFINE_SIMPLE_ATTRIBUTE(mca_recovery_fops, mca_recovery_get,
+			mca_recovery_set, "%llu\n");
 
 static int __init mcheck_debugfs_init(void)
 {
-	struct dentry *dmce, *ffake_panic;
+	struct dentry *dmce, *ffake_panic, *fmca_recovery;
 
 	dmce = mce_get_debugfs_dir();
 	if (!dmce)
@@ -2361,7 +2374,10 @@ static int __init mcheck_debugfs_init(vo
 					  &fake_panic_fops);
 	if (!ffake_panic)
 		return -ENOMEM;
-
+	fmca_recovery = debugfs_create_file("mca_recovery_force",0644,dmce,NULL,
+					&mca_recovery_fops);
+	if (!fmca_recovery)
+		return -ENOMEM;
 	return 0;
 }
 late_initcall(mcheck_debugfs_init);
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/