Patchwork [3/3] sparc/srmmu: use BITS_TO_LONGS() to calculate bitmap size

login
register
mail settings
Submitter Akinobu Mita
Date March 24, 2013, 8:55 a.m.
Message ID <1364115306-17716-3-git-send-email-akinobu.mita@gmail.com>
Download mbox | patch
Permalink /patch/230405/
State Rejected
Delegated to: David Miller
Headers show

Comments

Akinobu Mita - March 24, 2013, 8:55 a.m.
The size of bitmaps which is accessed by bitops must be a multiple of
the sizeof(long).  So it would be better to use BITS_TO_LONGS() to
calculate the bitmap size although it always be a multiple of the
sizeof(long)

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
---
 arch/sparc/mm/srmmu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
David Miller - March 25, 2013, 5:50 p.m.
From: Akinobu Mita <akinobu.mita@gmail.com>
Date: Sun, 24 Mar 2013 17:55:06 +0900

> The size of bitmaps which is accessed by bitops must be a multiple of
> the sizeof(long).  So it would be better to use BITS_TO_LONGS() to
> calculate the bitmap size although it always be a multiple of the
> sizeof(long)
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>

Same objection as patch #2, fixing a non-bug.

I'm not applying this, sorry.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Akinobu Mita - March 26, 2013, 9:17 a.m.
2013/3/26 David Miller <davem@davemloft.net>:
> From: Akinobu Mita <akinobu.mita@gmail.com>
> Date: Sun, 24 Mar 2013 17:55:06 +0900
>
>> The size of bitmaps which is accessed by bitops must be a multiple of
>> the sizeof(long).  So it would be better to use BITS_TO_LONGS() to
>> calculate the bitmap size although it always be a multiple of the
>> sizeof(long)
>>
>> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
>
> Same objection as patch #2, fixing a non-bug.

I thought it wasn't bug, but I was confused with bits and bytes, now
I realize that bitmap_bits is not always a multiple of the BITS_PER_LONG.
Because the value is set as below:

        bitmap_bits = srmmu_nocache_size >> SRMMU_NOCACHE_BITMAP_SHIFT;

srmmu_nocache_size is decided proportionally by the amount of system RAM
and it is rounded to a multiple of PAGE_SIZE.  SRMMU_NOCACHE_BITMAP_SHIFT
is defined as (PAGE_SHIFT - 4).  So it can only be said that bitmap_bits
is a multiple of 16.

So this patch (and patch 1/3) actually fix a bug.  I'll update the commit
messages and resend only the patches that fixing bug.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index c38bb72..f07a30a 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -280,7 +280,8 @@  static void __init srmmu_nocache_init(void)
 		SRMMU_NOCACHE_ALIGN_MAX, 0UL);
 	memset(srmmu_nocache_pool, 0, srmmu_nocache_size);
 
-	srmmu_nocache_bitmap = __alloc_bootmem(bitmap_bits >> 3, SMP_CACHE_BYTES, 0UL);
+	srmmu_nocache_bitmap = __alloc_bootmem(BITS_TO_LONGS(bitmap_bits) *
+				sizeof(unsigned long), SMP_CACHE_BYTES, 0UL);
 	bit_map_init(&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits);
 
 	srmmu_swapper_pg_dir = __srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE);