lkml.org 
[lkml]   [2012]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 08/10] ext2: use memweight()
On Sat 02-06-12 22:40:14, Akinobu Mita wrote:
> Use memweight() to count the total number of bits clear in memory area.
> This change only affects the code segments enabled by EXT2FS_DEBUG.
>
> This also fixes printk format warning that only reveals with EXT2FS_DEBUG.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Jan Kara <jack@suse.cz>
> Cc: linux-ext4@vger.kernel.org
> ---
>
> No changes from v1
>
> fs/ext2/balloc.c | 22 ++--------------------
> fs/ext2/ext2.h | 1 -
> fs/ext2/ialloc.c | 5 ++++-
> 3 files changed, 6 insertions(+), 22 deletions(-)
>
> diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
> index 1c36139..9095500 100644
> --- a/fs/ext2/balloc.c
> +++ b/fs/ext2/balloc.c
> @@ -1442,25 +1442,6 @@ ext2_fsblk_t ext2_new_block(struct inode *inode, unsigned long goal, int *errp)
> return ext2_new_blocks(inode, goal, &count, errp);
> }
>
> -#ifdef EXT2FS_DEBUG
> -
> -static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
> -
> -unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars)
> -{
> - unsigned int i;
> - unsigned long sum = 0;
> -
> - if (!map)
> - return (0);
> - for (i = 0; i < numchars; i++)
> - sum += nibblemap[map->b_data[i] & 0xf] +
> - nibblemap[(map->b_data[i] >> 4) & 0xf];
> - return (sum);
> -}
> -
> -#endif /* EXT2FS_DEBUG */
> -
So actually if you look at this function, you see that it counts bits in
map->b_data. That is guaranteed to be long aligned pointer so there's no
need for your memweight(). bitmap_weight() would be enough, especially
given that it can handle number of bits which is not a multiple of
BITS_PER_LONG.

For ext3 it's the same BTW.

Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR


\
 
 \ /
  Last update: 2012-06-04 13:01    [W:0.188 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site