cpu alloc: Add debugging checks Add some debugging check to CPU_OFFSET. If a processor is not available then BUG. If a processor is not online then show a warning. (At some point we need to get to the point where we only manage per cpu data for online processors.) Signed-off-by: Christoph Lameter --- include/linux/percpu.h | 11 +++++++++++ 1 file changed, 11 insertions(+) Index: linux-2.6/include/linux/percpu.h =================================================================== --- linux-2.6.orig/include/linux/percpu.h 2007-11-17 19:24:24.219224991 -0800 +++ linux-2.6/include/linux/percpu.h 2007-11-17 21:04:58.248390176 -0800 @@ -66,8 +66,19 @@ DECLARE_PER_CPU(cpumask_t, cpu_mask); * handled from an interrupt context). */ +#ifdef CONFIG_DEBUG_VM +#define CPU_OFFSET(__cpu) ({ \ + BUG_ON(!cpu_isset((__cpu), cpu_possible_map)); \ + if (system_state == SYSTEM_RUNNING) \ + WARN_ON(!cpu_isset((__cpu), cpu_online_map)); \ + (((unsigned long)(__cpu) << \ + (CONFIG_CPU_AREA_ORDER + PAGE_SHIFT))); \ +}) + +#else #define CPU_OFFSET(__cpu) \ ((unsigned long)(__cpu) << (CONFIG_CPU_AREA_ORDER + PAGE_SHIFT)) +#endif #define CPU_PTR(__p, __cpu) ((__typeof__(__p))((void *)(__p) + \ CPU_OFFSET(__cpu)))