[PATCH] broken bitmap_parse for ncpus > 32

From: Joe Korty
Date: Mon Mar 22 2004 - 15:24:56 EST


Andrew,
This patch replaces the call to bitmap_shift_right() in bitmap_parse()
with bitmap_shift_left().

This mental confusion between right and left did not show up in my
(userland) testing, as I foolishly wrote my own bitmap_shift routines
rather than drag over the kernel versions. And it did not show up in my
kernel testing because no shift routine is called when NR_CPUS <= 32.

I tested this in userland with the kernel's versions of bitmap_shift_*
and compiled a kernel and spot checked it on a 2-cpu system.

I also prepended comments to the bitmap_shift_* functions defining what
'left' and 'right' means. This is under the theory that if I and all the
reviewers were bamboozled, others in the future occasionally might be too.

Regards,
Joe

--- base/lib/bitmap.c 2004-03-10 21:55:43.000000000 -0500
+++ new/lib/bitmap.c 2004-03-22 14:41:03.000000000 -0500
@@ -71,6 +71,11 @@
}
EXPORT_SYMBOL(bitmap_complement);

+/*
+ * Shifting right (dividing) means moving bits in the MS -> LS bit
+ * direction. Zeros are fed into the vacated MS positions and the
+ * LS bits shifted off the bottom are lost.
+ */
void bitmap_shift_right(unsigned long *dst,
const unsigned long *src, int shift, int bits)
{
@@ -86,6 +91,11 @@
}
EXPORT_SYMBOL(bitmap_shift_right);

+/*
+ * Shifting left (multiplying) means moving bits in the LS -> MS
+ * direction. Zeros are fed into the vacated LS bit positions
+ * and those MS bits shifted off the top are lost.
+ */
void bitmap_shift_left(unsigned long *dst,
const unsigned long *src, int shift, int bits)
{
@@ -269,7 +279,7 @@
if (nchunks == 0 && chunk == 0)
continue;

- bitmap_shift_right(maskp, maskp, CHUNKSZ, nmaskbits);
+ bitmap_shift_left(maskp, maskp, CHUNKSZ, nmaskbits);
*maskp |= chunk;
nchunks++;
nbits += (nchunks == 1) ? nbits_to_hold_value(chunk) : CHUNKSZ;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/