Re: MCE, AMD: Hide smp-only code around CONFIG_SMP

From: Borislav Petkov
Date: Wed Feb 08 2012 - 05:20:03 EST


On Tue, Feb 07, 2012 at 10:57:46AM +0100, Ingo Molnar wrote:
> Could we please just define an obvious cpu_llc_shared_mask on UP
> (one bit long and set to 1) and not reintroduce the ugly
> #ifdef CONFIG_SMP?

Ok, here's a tentative proposed solution where I was trying not to
fatfinger the cpumask magic. Let me know if this is similar to what you
had in mind. The call to cpu_llc_shared_mask(int cpu) on UP might cause
a problem if the cpu arg is not 0 but it should not happen anyway and
there should be other problems with the caller side anyway.

Thanks.

--
From: Borislav Petkov <bp@xxxxxxxxx>
Date: Tue, 7 Feb 2012 21:40:22 +0100
Subject: [PATCH] MCE, AMD: Fix !CONFIG_SMP build

141168c36cde ("x86: Simplify code by removing a !SMP #ifdefs from
'struct cpuinfo_x86'") removed a bunch of CONFIG_SMP ifdefs around
code touching struct cpuinfo_x86 members but also caused the
following build error with Randy's randconfigs:

mce_amd.c:(.cpuinit.text+0x4723): undefined reference to `cpu_llc_shared_map'

Fix that by adding a UP version of the cpu_llc_shared_map, as Ingo
suggested.

Cc: Kevin Winchester <kjwinchester@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Randy Dunlap <rdunlap@xxxxxxxxxxxx>
Link: http://lkml.kernel.org/r/4F298A6C.6010101@xxxxxxxxxxxx
Signed-off-by: Borislav Petkov <bp@xxxxxxxxx>
---
arch/x86/include/asm/smp.h | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 0434c40..118754f 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -33,8 +33,15 @@ static inline bool cpu_has_ht_siblings(void)

DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map);
DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
-/* cpus sharing the last level cache: */
+
+#ifdef CONFIG_SMP
+/* CPUs sharing the last level cache: */
DECLARE_PER_CPU(cpumask_var_t, cpu_llc_shared_map);
+#else
+static DECLARE_BITMAP(cpu_llc_shared_bits, NR_CPUS) __read_mostly = { [0] = 1UL };
+static struct cpumask *const cpu_llc_shared_map = to_cpumask(cpu_llc_shared_bits);
+#endif
+
DECLARE_PER_CPU(u16, cpu_llc_id);
DECLARE_PER_CPU(int, cpu_number);

--
1.7.9

--
Regards/Gruss,
Boris.
--
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/