[lkml]   [2004]   [Jul]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
SubjectRe: [PATCH][2.6] first/next_cpu returns values > NR_CPUS
On Sat, Jul 31, 2004 at 04:52:18PM -0400, Zwane Mwaikambo wrote:
> 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 <>

This might save a couple of lines of code.

Index: hotplug-2.6.8-rc2/include/linux/cpumask.h
--- hotplug-2.6.8-rc2.orig/include/linux/cpumask.h 2004-07-29 04:44:59.000000000 -0700
+++ hotplug-2.6.8-rc2/include/linux/cpumask.h 2004-07-31 13:49:15.647650104 -0700
@@ -207,13 +207,13 @@
#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);
+ return min(NR_CPUS, find_first_bit(srcp->bits, nbits));

#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);
+ return min(NR_CPUS, find_next_bit(srcp->bits, nbits, n+1));

#define cpumask_of_cpu(cpu) \
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at
 \ /
  Last update: 2005-03-22 14:04    [W:0.044 / U:6.352 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site