[PATCH] xvmalloc: total_pages can be ulong

From: Ajeet Yadav
Date: Wed Dec 28 2011 - 00:38:34 EST


total_pages is u64, its too large value considering
that its in page unit on both 32-bit and 64-bit system
, therefore make it ulong.

Having done that we can use normal ++ and -- operators
instead of stat_inc() and stat_dec(), therefore
remove these functions as well.

Signed-off-by: Ajeet Yadav <ajeet.yadav.77@xxxxxxxxx>
---
drivers/staging/zram/xvmalloc.c | 16 +++-------------
drivers/staging/zram/xvmalloc_int.h | 2 +-
2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/zram/xvmalloc.c b/drivers/staging/zram/xvmalloc.c
index 1f9c508..2f989cf 100644
--- a/drivers/staging/zram/xvmalloc.c
+++ b/drivers/staging/zram/xvmalloc.c
@@ -26,16 +26,6 @@
#include "xvmalloc.h"
#include "xvmalloc_int.h"

-static void stat_inc(u64 *value)
-{
- *value = *value + 1;
-}
-
-static void stat_dec(u64 *value)
-{
- *value = *value - 1;
-}
-
static int test_flag(struct block_header *block, enum blockflags flag)
{
return block->prev & BIT(flag);
@@ -281,7 +271,7 @@ static int grow_pool(struct xv_pool *pool, gfp_t flags)
if (unlikely(!page))
return -ENOMEM;

- stat_inc(&pool->total_pages);
+ pool->total_pages++;

spin_lock(&pool->lock);
block = get_ptr_atomic(page, 0, KM_USER0);
@@ -472,7 +462,7 @@ void xv_free(struct xv_pool *pool, struct page
*page, u32 offset)
spin_unlock(&pool->lock);

__free_page(page);
- stat_dec(&pool->total_pages);
+ pool->total_pages--;
return;
}

@@ -505,6 +495,6 @@ EXPORT_SYMBOL_GPL(xv_get_object_size);
*/
u64 xv_get_total_size_bytes(struct xv_pool *pool)
{
- return pool->total_pages << PAGE_SHIFT;
+ return (u64)pool->total_pages << PAGE_SHIFT;
}
EXPORT_SYMBOL_GPL(xv_get_total_size_bytes);
diff --git a/drivers/staging/zram/xvmalloc_int.h
b/drivers/staging/zram/xvmalloc_int.h
index b5f1f7f..fcb0868 100644
--- a/drivers/staging/zram/xvmalloc_int.h
+++ b/drivers/staging/zram/xvmalloc_int.h
@@ -87,7 +87,7 @@ struct block_header {
struct xv_pool {
ulong flbitmap;
ulong slbitmap[MAX_FLI];
- u64 total_pages; /* stats */
+ ulong total_pages; /* stats */
struct freelist_entry freelist[NUM_FREE_LISTS];
spinlock_t lock;
};
--
1.6.0.3
--
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/