public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix cpu iterator on empty bitmask
@ 2004-04-27 23:52 Rusty Russell
  2004-04-28  0:05 ` William Lee Irwin III
  0 siblings, 1 reply; 6+ messages in thread
From: Rusty Russell @ 2004-04-27 23:52 UTC (permalink / raw)
  To: Joel Schopp, Anton Blanchard, Andrew Morton; +Cc: lkml - Kernel Mailing List

Name: Fix cpumask iterator over empty cpu set
Status: Trivial

Can't use _ffs() without first checking for zero, and if bits beyond
NR_CPUS set it'll give bogus results.  Use find_first_bit

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .26180-linux-2.6.6-rc2-bk5/include/asm-generic/cpumask_arith.h .26180-linux-2.6.6-rc2-bk5.updated/include/asm-generic/cpumask_arith.h
--- .26180-linux-2.6.6-rc2-bk5/include/asm-generic/cpumask_arith.h	2004-01-10 13:59:33.000000000 +1100
+++ .26180-linux-2.6.6-rc2-bk5.updated/include/asm-generic/cpumask_arith.h	2004-04-28 09:50:23.000000000 +1000
@@ -43,7 +43,7 @@
 #define cpus_promote(map)		({ map; })
 #define cpumask_of_cpu(cpu)		({ ((cpumask_t)1) << (cpu); })
 
-#define first_cpu(map)			__ffs(map)
+#define first_cpu(map)			find_first_bit(&(map), NR_CPUS)
 #define next_cpu(cpu, map)		find_next_bit(&(map), NR_CPUS, cpu + 1)
 
 #endif /* __ASM_GENERIC_CPUMASK_ARITH_H */
-- 
Anyone who quotes me in their signature is an idiot -- Rusty Russell


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-04-28  2:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-27 23:52 [PATCH] Fix cpu iterator on empty bitmask Rusty Russell
2004-04-28  0:05 ` William Lee Irwin III
2004-04-28  1:22   ` Rusty Russell
2004-04-28  1:31     ` Paul Jackson
2004-04-28  1:57       ` William Lee Irwin III
2004-04-28  2:18         ` Paul Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox