linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xvmalloc: total_pages can be ulong
@ 2011-12-28  5:50 Ajeet Yadav
  2011-12-29 13:58 ` Nitin Gupta
  2012-02-09  1:11 ` Greg KH
  0 siblings, 2 replies; 7+ messages in thread
From: Ajeet Yadav @ 2011-12-28  5:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, Nitin Gupta

>From 4763266cb0077d1082d4a1ef941448e9b4eb55ca Mon Sep 17 00:00:00 2001
From: Ajeet Yadav <ajeet.yadav.77@gmail.com>
Date: Wed, 28 Dec 2011 11:08:34 +0530
Subject: [PATCH] xvmalloc: total_pages can be ulong

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@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-02-11  6:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-28  5:50 [PATCH] xvmalloc: total_pages can be ulong Ajeet Yadav
2011-12-29 13:58 ` Nitin Gupta
2011-12-30  4:51   ` Ajeet Yadav
2012-02-09  1:11 ` Greg KH
2012-02-10 10:21   ` Ajeet Yadav
2012-02-10 13:58   ` Nitin Gupta
2012-02-11  6:43     ` Ajeet Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).