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 | 10 ++++++++++ 1 file changed, 10 insertions(+) Index: linux-2.6/include/linux/percpu.h =================================================================== --- linux-2.6.orig/include/linux/percpu.h 2007-11-17 18:07:54.141023274 -0800 +++ linux-2.6/include/linux/percpu.h 2007-11-17 18:09:44.684773088 -0800 @@ -66,8 +66,18 @@ DECLARE_PER_CPU(cpumask_t, cpu_mask); * handled from an interrupt context). */ +#ifdef CONFIG_DEBUG_VM +#define CPU_OFFSET(__cpu) \ +({ + BUG_ON(!cpu_isset(i, cpu_possible_map)); + WARN_ON(!cpu_isset(i, 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)))