All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][2.6] first/next_cpu returns values > NR_CPUS
@ 2004-07-31 20:52 Zwane Mwaikambo
  2004-07-31 20:57 ` William Lee Irwin III
  2004-08-01  6:21 ` Paul Jackson
  0 siblings, 2 replies; 20+ messages in thread
From: Zwane Mwaikambo @ 2004-07-31 20:52 UTC (permalink / raw)
  To: Linux Kernel; +Cc: Andrew Morton, Paul Jackson

The following caused some fireworks whilst merging i386 cpu hotplug.

any_online_cpu(0x2) returns 32 on i386 if we're forced to continue past
the only set bit due to the additional find_first_bit in the
find_next_bit i386 implementation. Not wanting to change current
behaviour in the bitops primitives and since the NR_CPUS thing is a
cpumask issue, i've opted to fix next_cpu() and first_cpu() instead.

Signed-off-by: Zwane Mwaikambo <zwane@fsmlabs.com>

Index: linux-2.6.8-rc2-mm1-lch/include/linux/cpumask.h
===================================================================
RCS file: /home/cvsroot/linux-2.6.8-rc2-mm1/include/linux/cpumask.h,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 cpumask.h
--- linux-2.6.8-rc2-mm1-lch/include/linux/cpumask.h	28 Jul 2004 14:35:22 -0000	1.1.1.1
+++ linux-2.6.8-rc2-mm1-lch/include/linux/cpumask.h	31 Jul 2004 17:57:12 -0000
@@ -207,13 +207,19 @@ static inline void __cpus_shift_left(cpu
 #define first_cpu(src) __first_cpu(&(src), NR_CPUS)
 static inline int __first_cpu(const cpumask_t *srcp, int nbits)
 {
-	return find_first_bit(srcp->bits, nbits);
+	int cpu = find_first_bit(srcp->bits, nbits);
+	if (cpu > NR_CPUS)
+		cpu = NR_CPUS;
+	return cpu;
 }

 #define next_cpu(n, src) __next_cpu((n), &(src), NR_CPUS)
 static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits)
 {
-	return find_next_bit(srcp->bits, nbits, n+1);
+	int cpu = find_next_bit(srcp->bits, nbits, n+1);
+	if (cpu > NR_CPUS)
+		cpu = NR_CPUS;
+	return cpu;
 }

 #define cpumask_of_cpu(cpu)						\

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

end of thread, other threads:[~2004-08-05 18:30 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-31 20:52 [PATCH][2.6] first/next_cpu returns values > NR_CPUS Zwane Mwaikambo
2004-07-31 20:57 ` William Lee Irwin III
2004-07-31 23:02   ` Zwane Mwaikambo
2004-08-01  6:21 ` Paul Jackson
2004-08-01  7:22   ` Zwane Mwaikambo
2004-08-01 11:20     ` Paul Jackson
2004-08-01 14:51       ` Zwane Mwaikambo
2004-08-01 12:40     ` William Lee Irwin III
2004-08-01 13:05       ` Paul Jackson
2004-08-01 13:10         ` William Lee Irwin III
2004-08-01 13:36           ` Paul Jackson
2004-08-01 13:41             ` William Lee Irwin III
2004-08-01 13:47               ` Paul Jackson
2004-08-02 22:00               ` Matthew Dobson
2004-08-05 16:50                 ` OGAWA Hirofumi
2004-08-05 17:01                   ` William Lee Irwin III
2004-08-05 17:42                   ` Andrew Morton
2004-08-05 18:13                     ` Roman Zippel
2004-08-01 14:54       ` Zwane Mwaikambo
2004-08-01 15:05         ` William Lee Irwin III

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.