Commit f9bbb9e8 authored by William Lee Irwin III's avatar William Lee Irwin III Committed by Linus Torvalds

[PATCH] first/next_cpu returns values > NR_CPUS

Zwane Mwaikambo <zwane@fsmlabs.com> 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.

This might save a couple of lines of code.

From: <akpm@osdl.org>

  Fix cross-arch ulong/int disaster with find_next_bit().
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 1a87fc37
......@@ -73,6 +73,7 @@
* inside a macro, the way we do the other calls.
*/
#include <linux/kernel.h>
#include <linux/threads.h>
#include <linux/bitmap.h>
#include <asm/bug.h>
......@@ -207,13 +208,13 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
#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_t(int, nbits, 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_t(int, nbits, find_next_bit(srcp->bits, nbits, n+1));
}
#define cpumask_of_cpu(cpu) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment