[PATCH v4 7/8] staging: zcache: introduce zero-filled page stat count

From: Wanpeng Li
Date: Tue Mar 19 2013 - 05:26:56 EST


Introduce zero-filled page statistics to monitor the number of
zero-filled pages.

Acked-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
Signed-off-by: Wanpeng Li <liwanp@xxxxxxxxxxxxxxxxxx>
---
drivers/staging/zcache/debug.h | 15 +++++++++++++++
drivers/staging/zcache/zcache-main.c | 5 +++++
2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/zcache/debug.h b/drivers/staging/zcache/debug.h
index 8ec82d4..178bf75 100644
--- a/drivers/staging/zcache/debug.h
+++ b/drivers/staging/zcache/debug.h
@@ -122,6 +122,21 @@ static inline void dec_zcache_pers_zpages(unsigned zpages)
zcache_pers_zpages = atomic_sub_return(zpages, &zcache_pers_zpages_atomic);
}

+extern ssize_t zcache_zero_filled_pages;
+static atomic_t zcache_zero_filled_pages_atomic = ATOMIC_INIT(0);
+extern ssize_t zcache_zero_filled_pages_max;
+static inline void inc_zcache_zero_filled_pages(void)
+{
+ zcache_zero_filled_pages = atomic_inc_return(
+ &zcache_zero_filled_pages_atomic);
+ if (zcache_zero_filled_pages > zcache_zero_filled_pages_max)
+ zcache_zero_filled_pages_max = zcache_zero_filled_pages;
+}
+static inline void dec_zcache_zero_filled_pages(void)
+{
+ zcache_zero_filled_pages = atomic_dec_return(
+ &zcache_zero_filled_pages_atomic);
+}
static inline unsigned long curr_pageframes_count(void)
{
return zcache_pageframes_alloced -
diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index d1118f0..f8ba619 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -176,6 +176,8 @@ ssize_t zcache_pers_ate_eph;
ssize_t zcache_pers_ate_eph_failed;
ssize_t zcache_evicted_eph_zpages;
ssize_t zcache_evicted_eph_pageframes;
+ssize_t zcache_zero_filled_pages;
+ssize_t zcache_zero_filled_pages_max;

/* Used by this code. */
ssize_t zcache_last_active_file_pageframes;
@@ -404,6 +406,7 @@ static void *zcache_pampd_eph_create(char *data, size_t size, bool raw,
if (page_is_zero_filled(page)) {
clen = 0;
zero_filled = true;
+ inc_zcache_zero_filled_pages();
goto got_pampd;
}

@@ -470,6 +473,7 @@ static void *zcache_pampd_pers_create(char *data, size_t size, bool raw,
if (page_is_zero_filled(page)) {
clen = 0;
zero_filled = true;
+ inc_zcache_zero_filled_pages();
goto got_pampd;
}

@@ -682,6 +686,7 @@ static int zcache_pampd_get_data_and_free(char *data, size_t *sizep, bool raw,
zpages = 1;
if (!raw)
*sizep = PAGE_SIZE;
+ dec_zcache_zero_filled_pages();
goto zero_fill;
}

--
1.7.7.6

--
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/