* [PATCH 2/5] Fix bitmap_scnprintf_len()
@ 2008-05-07 22:26 Alexey Dobriyan
2008-05-08 14:59 ` Bert Wesarg
0 siblings, 1 reply; 2+ messages in thread
From: Alexey Dobriyan @ 2008-05-07 22:26 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel, travis
bitmap_scnprintf_len() returns 36 (thirty six) for NR_CPUS=2 which is
ridiculous. So, rewrite the whole thing. Fixed version allows correct
seq_bitmap/seq_cpumask.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
include/linux/bitmap.h | 2 +-
lib/bitmap.c | 12 ++++--------
2 files changed, 5 insertions(+), 9 deletions(-)
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -110,7 +110,7 @@ extern int __bitmap_weight(const unsigned long *bitmap, int bits);
extern int bitmap_scnprintf(char *buf, unsigned int len,
const unsigned long *src, int nbits);
-extern int bitmap_scnprintf_len(unsigned int len);
+extern int bitmap_scnprintf_len(unsigned int nr_bits);
extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user,
unsigned long *dst, int nbits);
extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -318,16 +318,12 @@ EXPORT_SYMBOL(bitmap_scnprintf);
/**
* bitmap_scnprintf_len - return buffer length needed to convert
* bitmap to an ASCII hex string.
- * @len: number of bits to be converted
+ * @nr_bits: number of bits to be converted
*/
-int bitmap_scnprintf_len(unsigned int len)
+int bitmap_scnprintf_len(unsigned int nr_bits)
{
- /* we need 9 chars per word for 32 bit words (8 hexdigits + sep/null) */
- int bitslen = ALIGN(len, CHUNKSZ);
- int wordlen = CHUNKSZ / 4;
- int buflen = (bitslen / wordlen) * (wordlen + 1) * sizeof(char);
-
- return buflen;
+ unsigned int nr_nibbles = ALIGN(nr_bits, 4) / 4;
+ return nr_nibbles + ALIGN(nr_nibbles, CHUNKSZ / 4) / (CHUNKSZ / 4) - 1;
}
EXPORT_SYMBOL(bitmap_scnprintf_len);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 2/5] Fix bitmap_scnprintf_len()
2008-05-07 22:26 [PATCH 2/5] Fix bitmap_scnprintf_len() Alexey Dobriyan
@ 2008-05-08 14:59 ` Bert Wesarg
0 siblings, 0 replies; 2+ messages in thread
From: Bert Wesarg @ 2008-05-08 14:59 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: akpm, linux-kernel, travis
On Thu, May 8, 2008 at 12:26 AM, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> bitmap_scnprintf_len() returns 36 (thirty six) for NR_CPUS=2 which is
> ridiculous. So, rewrite the whole thing. Fixed version allows correct
> seq_bitmap/seq_cpumask.
Reported-here: http://thread.gmane.org/gmane.linux.kernel/671725
>
> Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Bert Wesarg <bert.wesarg@googlemail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-08 14:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-07 22:26 [PATCH 2/5] Fix bitmap_scnprintf_len() Alexey Dobriyan
2008-05-08 14:59 ` Bert Wesarg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®