[PATCH][2.6] first/next_cpu returns values > NR_CPUS
From: Zwane Mwaikambo (zwane_at_fsmlabs.com)
Date: 07/31/04
- Previous message: Jesper Juhl: "[PATCH] Fix up return value from dio_find() (fixing a FIXME)"
- Next in thread: William Lee Irwin III: "Re: [PATCH][2.6] first/next_cpu returns values > NR_CPUS"
- Reply: William Lee Irwin III: "Re: [PATCH][2.6] first/next_cpu returns values > NR_CPUS"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 31 Jul 2004 16:52:18 -0400 (EDT) To: Linux Kernel <linux-kernel@vger.kernel.org>
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) \
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Previous message: Jesper Juhl: "[PATCH] Fix up return value from dio_find() (fixing a FIXME)"
- Next in thread: William Lee Irwin III: "Re: [PATCH][2.6] first/next_cpu returns values > NR_CPUS"
- Reply: William Lee Irwin III: "Re: [PATCH][2.6] first/next_cpu returns values > NR_CPUS"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Re: [PATCH][2.6] first/next_cpu returns values > NR_CPUS
... > The following caused some fireworks whilst merging i386 cpu hotplug. ...
> behaviour in the bitops primitives and since the NR_CPUS thing is a ... send the line
"unsubscribe linux-kernel" in ... (Linux-Kernel) - Re: Merging relayfs?
... relayfs client still need some ... I would prefer "unsigned int" over
just "unsigned" ... In general I'm not against merging, but I have a few ideas for further
... send the line "unsubscribe linux-kernel" in ... (Linux-Kernel) - Re: User space out of memory approach
... confirmed fix for this available. ... Merging a fix which helps only
0,001 % of the users to hide the mess ... instead of fixing the real problem is a real
interesting engineering ... send the line "unsubscribe linux-kernel" in ... (Linux-Kernel) - Re: 2.7 thoughts
... > Although sarcasm aside, a couple of ideas that have been bantered around ...
CPU hotplug: ... RAM hotplug: has already been discussed in several threads, sure
needs brain, ... send the line "unsubscribe linux-kernel" in ... (Linux-Kernel) - Re: smp/swsusp done right
... Unlike previous hacks, it uses cpu hotplug ... >> Test this if you can,
and report any problems. ... I guess it is thank you -- I got rid of ugly FIXME
that would ... send the line "unsubscribe linux-kernel" in ... (Linux-Kernel)