[PATCH] arch/x86/mm/kmemcheck/kmemcheck.c: use max cpus

From: Sudip Mukherjee
Date: Sat Oct 31 2015 - 05:34:44 EST


If SMP is enabled then to use kmemcheck we are limiting to one CPU. And
if kmemcheck selftest fails, we are disabling kmemcheck and returning. But
we are still using single CPU even though kmemcheck is disabled.
Use the original max cpu value if kmemcheck selftest fails.

Signed-off-by: Sudip Mukherjee <sudip@xxxxxxxxxxxxxxx>
---
arch/x86/mm/kmemcheck/kmemcheck.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
index b4f2e7e..4f09508 100644
--- a/arch/x86/mm/kmemcheck/kmemcheck.c
+++ b/arch/x86/mm/kmemcheck/kmemcheck.c
@@ -52,8 +52,12 @@ int __init kmemcheck_init(void)
#ifdef CONFIG_SMP
/*
* Limit SMP to use a single CPU. We rely on the fact that this code
- * runs before SMP is set up.
+ * runs before SMP is set up. Save the original value so that if
+ * kmemcheck_selftest() fails we can use the original value
+ * instead of using single CPU.
*/
+ unsigned int orig_max_cpu = setup_max_cpus;
+
if (setup_max_cpus > 1) {
printk(KERN_INFO
"kmemcheck: Limiting number of CPUs to 1.\n");
@@ -64,6 +68,9 @@ int __init kmemcheck_init(void)
if (!kmemcheck_selftest()) {
printk(KERN_INFO "kmemcheck: self-tests failed; disabling\n");
kmemcheck_enabled = 0;
+#ifdef CONFIG_SMP
+ setup_max_cpus = orig_max_cpu;
+#endif
return -EINVAL;
}

--
1.9.1

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