
From: William Lee Irwin III <wli@holomorphy.com>

any_online_cpu() is required to and with cpu_online_map before
attempting to find an online cpu somewhere in the map; this patch adds
that logic to the implementation(s) of any_online_cpu().



 include/asm-generic/cpumask_arith.h |    7 ++++++-
 include/asm-generic/cpumask_array.h |    8 +++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff -puN include/asm-generic/cpumask_arith.h~any_online_cpu-fix include/asm-generic/cpumask_arith.h
--- 25/include/asm-generic/cpumask_arith.h~any_online_cpu-fix	2003-09-11 01:04:24.000000000 -0700
+++ 25-akpm/include/asm-generic/cpumask_arith.h	2003-09-11 01:04:24.000000000 -0700
@@ -27,7 +27,12 @@
 #define cpus_shift_right(dst, src, n)	do { dst = (src) >> (n); } while (0)
 #define cpus_shift_left(dst, src, n)	do { dst = (src) << (n); } while (0)
 
-#define any_online_cpu(map)		({ (map) ? first_cpu(map) : NR_CPUS; })
+#define any_online_cpu(map)			\
+({						\
+	cpumask_t __tmp__;			\
+	cpus_and(__tmp__, map, cpu_online_map);	\
+	__tmp__ ? first_cpu(__tmp__) : NR_CPUS;	\
+})
 
 #define CPU_MASK_ALL	(~((cpumask_t)0) >> (8*sizeof(cpumask_t) - NR_CPUS))
 #define CPU_MASK_NONE	((cpumask_t)0)
diff -puN include/asm-generic/cpumask_array.h~any_online_cpu-fix include/asm-generic/cpumask_array.h
--- 25/include/asm-generic/cpumask_array.h~any_online_cpu-fix	2003-09-11 01:04:24.000000000 -0700
+++ 25-akpm/include/asm-generic/cpumask_array.h	2003-09-11 01:04:24.000000000 -0700
@@ -36,7 +36,13 @@
 					cpu_set(cpu, __cpu_mask);	\
 					__cpu_mask;			\
 				})
-#define any_online_cpu(map)	find_first_bit((map).mask, NR_CPUS)
+#define any_online_cpu(map)			\
+({						\
+	cpumask_t __tmp__;			\
+	cpus_and(__tmp__, map, cpu_online_map);	\
+	find_first_bit(__tmp__.mask, NR_CPUS);	\
+})
+
 
 /*
  * um, these need to be usable as static initializers

_
