[PATCH 2/3] Added counters for compression and decompression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Florian Schmaus <fschmaus@xxxxxxxxx>
---
 drivers/staging/zcache/zcache-main.c |   54 ++++++++++++++++++++++------------
 1 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
index 1bece03..d2f9d9e 100644
--- a/drivers/staging/zcache/zcache-main.c
+++ b/drivers/staging/zcache/zcache-main.c
@@ -95,25 +95,7 @@ enum comp_op {
 
 static inline int zcache_comp_op(enum comp_op op,
 				const u8 *src, unsigned int slen,
-				u8 *dst, unsigned int *dlen)
-{
-	struct crypto_comp *tfm;
-	int ret;
-
-	BUG_ON(!zcache_comp_pcpu_tfms);
-	tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, get_cpu());
-	BUG_ON(!tfm);
-	switch (op) {
-	case ZCACHE_COMPOP_COMPRESS:
-		ret = crypto_comp_compress(tfm, src, slen, dst, dlen);
-		break;
-	case ZCACHE_COMPOP_DECOMPRESS:
-		ret = crypto_comp_decompress(tfm, src, slen, dst, dlen);
-		break;
-	}
-	put_cpu();
-	return ret;
-}
+				 u8 *dst, unsigned int *dlen);
 
 /**********
  * Compression buddies ("zbud") provides for packing two (or, possibly
@@ -1057,6 +1039,8 @@ static atomic_t zcache_curr_obj_count = ATOMIC_INIT(0);
 static unsigned long zcache_curr_obj_count_max;
 static atomic_t zcache_curr_objnode_count = ATOMIC_INIT(0);
 static unsigned long zcache_curr_objnode_count_max;
+static atomic_t zcache_compress_count = ATOMIC_INIT(0);
+static atomic_t zcache_decompress_count = ATOMIC_INIT(0);
 
 /*
  * to avoid memory allocation recursion (e.g. due to direct reclaim), we
@@ -1521,6 +1505,8 @@ ZCACHE_SYSFS_RO_ATOMIC(zbud_curr_raw_pages);
 ZCACHE_SYSFS_RO_ATOMIC(zbud_curr_zpages);
 ZCACHE_SYSFS_RO_ATOMIC(curr_obj_count);
 ZCACHE_SYSFS_RO_ATOMIC(curr_objnode_count);
+ZCACHE_SYSFS_RO_ATOMIC(compress_count);
+ZCACHE_SYSFS_RO_ATOMIC(decompress_count);
 ZCACHE_SYSFS_RO_CUSTOM(zbud_unbuddied_list_counts,
 			zbud_show_unbuddied_list_counts);
 ZCACHE_SYSFS_RO_CUSTOM(zbud_cumul_chunk_counts,
@@ -1564,6 +1550,8 @@ static struct attribute *zcache_attrs[] = {
 	&zcache_zv_max_mean_zsize_attr.attr,
 	&zcache_zv_page_count_policy_percent_attr.attr,
 	&zcache_freeze_attr.attr,
+	&zcache_compress_count_attr.attr,
+	&zcache_decompress_count_attr.attr,
 	NULL,
 };
 
@@ -1574,6 +1562,34 @@ static struct attribute_group zcache_attr_group = {
 
 #endif /* CONFIG_SYSFS */
 
+static inline int zcache_comp_op(enum comp_op op,
+				const u8 *src, unsigned int slen,
+				 u8 *dst, unsigned int *dlen)
+{
+	struct crypto_comp *tfm;
+	int ret;
+
+	BUG_ON(!zcache_comp_pcpu_tfms);
+	tfm = *per_cpu_ptr(zcache_comp_pcpu_tfms, get_cpu());
+	BUG_ON(!tfm);
+	switch (op) {
+	case ZCACHE_COMPOP_COMPRESS:
+		ret = crypto_comp_compress(tfm, src, slen, dst, dlen);
+#ifdef CONFIG_SYSFS
+		atomic_inc(&zcache_compress_count);
+#endif
+		break;
+	case ZCACHE_COMPOP_DECOMPRESS:
+		ret = crypto_comp_decompress(tfm, src, slen, dst, dlen);
+#ifdef CONFIG_SYSFS
+		atomic_inc(&zcache_decompress_count);
+#endif
+		break;
+	}
+	put_cpu();
+	return ret;
+}
+
 /*
  * zcache shrinker interface (only useful for ephemeral pages, so zbud only)
  */
-- 
1.7.5.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux