diff options
author | Andrew Morton <akpm@osdl.org> | 2004-04-11 23:00:10 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-04-11 23:00:10 -0700 |
commit | f951179269c98ac7b58dcfa3de2e68d4a0a3d680 (patch) | |
tree | 6f92f0acbf9bd1052b1705b7d2832f4da731501b /lib | |
parent | 5362a3548872e1d7c7b3926f1519999b315e9825 (diff) | |
download | history-f951179269c98ac7b58dcfa3de2e68d4a0a3d680.tar.gz |
[PATCH] Broken bitmap_parse for ncpus > 32
From: Joe Korty <joe.korty@ccur.com>
This patch replaces the call to bitmap_shift_right() in bitmap_parse() with
bitmap_shift_left().
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bitmap.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index 6793ac0029151a..68abf679808bf4 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c @@ -71,6 +71,17 @@ void bitmap_complement(unsigned long *bitmap, int bits) } EXPORT_SYMBOL(bitmap_complement); +/* + * bitmap_shift_write - logical right shift of the bits in a bitmap + * @dst - destination bitmap + * @src - source bitmap + * @nbits - shift by this many bits + * @bits - bitmap size, in bits + * + * 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 +97,17 @@ void bitmap_shift_right(unsigned long *dst, } EXPORT_SYMBOL(bitmap_shift_right); +/* + * bitmap_shift_left - logical left shift of the bits in a bitmap + * @dst - destination bitmap + * @src - source bitmap + * @nbits - shift by this many bits + * @bits - bitmap size, in bits + * + * 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 +291,7 @@ int bitmap_parse(const char __user *ubuf, unsigned int ubuflen, 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; |